/* 티끌 · 시안 A "장부" */
:root {
  --paper: #F6F4EE;
  --card: #FFFFFF;
  --ink: #1B1D1A;
  --muted: #5E625B;
  --rule: #DEDAD0;
  --rule-soft: #EEEBE3;
  --inc: #1F5FBF;
  --exp: #A84C0C;
  --warn-bg: #FFF7EF;
  --warn-line: #EBC9A8;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --sans: 'IBM Plex Sans KR', system-ui, -apple-system, 'Apple SD Gothic Neo', sans-serif;
}
* { box-sizing: border-box; }
/* hidden 속성이 display 지정보다 이기게 (빈 시트가 화면을 덮던 문제) */
[hidden] { display: none !important; }
html, body { margin: 0; background: #E9E6DD; }
body { font-family: var(--sans); color: var(--ink); -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--inc); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.inc { color: var(--inc); }
.exp { color: var(--exp); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app { max-width: 480px; margin: 0 auto; min-height: 100vh; background: var(--paper); display: flex; flex-direction: column; position: relative; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 18px 20px 0; }
.brand-name { display: inline-flex; align-items: center; gap: 8px; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; }
.brand-sub { font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 8px; gap: 8px; }
.top h1 { margin: 0; font-size: 20px; font-weight: 700; text-align: center; }
.top .eyebrow { font-size: 12px; color: var(--muted); letter-spacing: .08em; text-align: center; }
.top .title-left { font-size: 22px; font-weight: 700; margin: 0; }
.iconbtn { width: 44px; height: 44px; border: 1px solid var(--rule); border-radius: 12px; background: var(--card); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.iconbtn.ghost { border: 0; background: transparent; }
.iconbtn svg { width: 20px; height: 20px; }

main.view { flex: 1; display: flex; flex-direction: column; gap: 16px; padding: 8px 20px 28px; }
.card { background: var(--card); border: 1px solid var(--rule); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card h2, .sec-title { margin: 0; font-size: 15px; font-weight: 700; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row-base { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }

.banner { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 14px; padding: 12px 14px; font-size: 13px; line-height: 1.55; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.banner.info { background: #EEF3FB; border-color: #C7D6EE; }

.summary { background: var(--ink); color: var(--paper); border-radius: 20px; padding: 22px 20px; display: flex; flex-direction: column; gap: 16px; }
.summary .lbl { font-size: 13px; color: #C9C6BC; }
.summary .big { font-family: var(--mono); font-size: 32px; font-weight: 600; margin-top: 4px; }
.summary .big small { font-family: var(--sans); font-size: 17px; font-weight: 500; margin-left: 4px; }
.summary .grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; border-top: 1px dashed #4A4D47; padding-top: 14px; }
.summary .mid { font-family: var(--mono); font-size: 17px; font-weight: 600; }
.summary .tiny { font-size: 11px; color: #C9C6BC; margin-top: 2px; line-height: 1.4; }
.summary .pos { color: #8FB7F5; }
.summary .neg { color: #F2A97A; }

.btn { min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--rule); background: var(--card); cursor: pointer; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; color: var(--ink); }
.btn.dark { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 600; }
.btn.warn { background: var(--exp); color: #fff; border-color: var(--exp); font-weight: 600; }
.btn.danger { color: #9A2B12; border-color: #E5BFB3; }
.btn.block { width: 100%; min-height: 52px; font-size: 16px; font-weight: 700; border-radius: 14px; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btns > .grow { flex: 1; }

.check { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; font-size: 14px; line-height: 1.5; }

.bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; gap: 2px; background: var(--rule-soft); }
.legend { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.legend .li { display: flex; align-items: center; gap: 8px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend .li .name { flex: 1; }
.meter { height: 8px; background: var(--rule-soft); border-radius: 4px; overflow: hidden; }
.meter > div { height: 100%; background: var(--ink); }
.meter.over > div { background: var(--exp); }

/* 달력 */
.cal-head, .cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.cal-head { font-size: 11px; color: var(--muted); text-align: center; }
.cal button { aspect-ratio: 1; min-height: 40px; border-radius: 8px; border: 0; padding: 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-family: var(--mono); font-size: 12px; font-weight: 600; }
.cal .l0 { background: var(--paper); color: var(--muted); }
.cal .l1 { background: #F3E3D6; }
.cal .l2 { background: #CB8350; }
.cal .l3 { background: var(--exp); color: #fff; }
.cal .future { background: var(--card); color: #8A8D85; border: 1px dashed var(--rule); }
.cal .sel { outline: 2px solid var(--ink); outline-offset: 0; }
.cal .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--inc); }
.cal .l3 .dot { background: #fff; }
.cal-detail { background: var(--paper); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }

/* 내역 */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--rule); background: var(--card); cursor: pointer; font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 600; }
.day-h { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 8px; }
.list { background: var(--card); border: 1px solid var(--rule); border-radius: 16px; overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 64px; border: 0; border-bottom: 1px solid var(--rule-soft); background: transparent; width: 100%; text-align: left; cursor: pointer; }
.item:last-child { border-bottom: 0; }
.tag { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.tag.card { background: var(--ink); color: var(--paper); }
.tag.cash { background: #F4E3D3; color: #7A3608; }
.tag.account { background: #DFE8F7; color: #174a95; }
.tag.paymoney { background: #EEF0E1; color: #4F5C1E; }
.tag.phone { background: #ECEAF2; color: #4A4658; }
.tag.point { background: #F3EBD8; color: #6B4E12; }
.tag.work { background: #DFE8F7; color: #174a95; }
.item .mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item .t { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { font-size: 12px; color: var(--muted); }
.item .right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.amt { font-family: var(--mono); font-size: 15px; font-weight: 600; }
.amt.inc { color: var(--inc); }
.amt.off { color: var(--muted); text-decoration: line-through; }
.note { font-size: 11px; color: var(--muted); text-align: right; }
.badge { align-self: flex-start; font-size: 11px; font-weight: 600; color: #8A3F0A; background: #FFF1E4; border-radius: 6px; padding: 2px 6px; }
.empty { text-align: center; color: var(--muted); font-size: 14px; padding: 28px 0; }

/* 아래 메뉴 */
.tabbar { position: sticky; bottom: 0; background: var(--card); border-top: 1px solid var(--rule); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 6px 8px calc(10px + env(safe-area-inset-bottom)); z-index: 5; }
.tabbar.six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.tabbar a { min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); text-decoration: none; font-size: 11px; }
.tabbar a[aria-current="page"] { color: var(--ink); font-weight: 700; }
.tabbar svg { width: 22px; height: 22px; }
.tabbar .plus span { width: 48px; height: 48px; border-radius: 16px; background: var(--ink); color: var(--paper); display: flex; align-items: center; justify-content: center; }

/* 시트(입력·상세) */
.sheet { position: fixed; inset: 0; background: rgba(27, 29, 26, .35); z-index: 20; display: flex; justify-content: center; }
.sheet .panel { width: 100%; max-width: 480px; background: var(--paper); overflow-y: auto; display: flex; flex-direction: column; }
.sheet .panel-top { display: flex; align-items: center; gap: 8px; padding: 14px 12px 6px; position: sticky; top: 0; background: var(--paper); z-index: 1; }
.sheet .panel-top h2 { margin: 0; font-size: 18px; font-weight: 700; flex: 1; }
.form { display: flex; flex-direction: column; gap: 18px; padding: 4px 20px 32px; }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; background: #E9E6DD; border-radius: 14px; padding: 4px; }
.seg button { min-height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); font-weight: 700; box-shadow: 0 1px 2px rgba(27, 29, 26, .15); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .legend-l { font-size: 13px; color: var(--muted); }
.input { min-height: 48px; border: 1px solid var(--rule); border-radius: 12px; background: var(--card); padding: 0 12px; font-size: 15px; width: 100%; }
.amount-in { display: flex; align-items: baseline; gap: 6px; border-bottom: 3px solid var(--ink); padding-bottom: 8px; }
.amount-in input { flex: 1; min-width: 0; border: 0; background: transparent; font-family: var(--mono); font-size: 44px; font-weight: 600; line-height: 1.15; outline-offset: 4px; }
.amount-in span { font-size: 22px; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.opt { min-height: 48px; border-radius: 12px; border: 1px solid var(--rule); background: var(--card); cursor: pointer; font-size: 14px; padding: 0 6px; }
.opt[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 600; }
.opt.link { border-style: dashed; color: var(--muted); display: flex; align-items: center; justify-content: center; text-align: center; text-decoration: none; font-size: 13px; line-height: 1.3; }
.hint { margin: 0; font-size: 13px; line-height: 1.55; color: #3F433D; background: var(--card); border: 1px solid var(--rule); border-radius: 12px; padding: 10px 12px; }
.toggle { display: flex; align-items: center; gap: 12px; min-height: 48px; background: var(--card); border: 1px solid var(--rule); border-radius: 12px; padding: 0 14px; font-size: 14px; cursor: pointer; }
.toggle input { width: 20px; height: 20px; accent-color: var(--ink); }
.sav-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) 44px; gap: 8px; align-items: center; }
.sav-row select, .sav-row input { min-height: 44px; border: 1px solid var(--rule); border-radius: 10px; background: var(--card); padding: 0 10px; width: 100%; }
.sav-row input { font-family: var(--mono); }
.dl { display: grid; grid-template-columns: 80px minmax(0, 1fr); row-gap: 8px; font-size: 14px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
.radio { min-height: 48px; display: flex; align-items: center; gap: 12px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--rule); background: var(--card); cursor: pointer; font-size: 14px; text-align: left; width: 100%; }
.radio .dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #B9B4A7; flex-shrink: 0; }
.radio[aria-checked="true"] { background: var(--warn-bg); border-color: var(--exp); font-weight: 600; }
.radio[aria-checked="true"] .dot { border: 6px solid var(--exp); }

/* 통계 */
.bars6 { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; align-items: end; height: 180px; border-bottom: 1px solid var(--rule); }
.bars6 .col { display: flex; align-items: flex-end; justify-content: center; gap: 3px; height: 100%; }
.bars6 .b { width: 14px; border-radius: 4px 4px 0 0; }
.bars6-l { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; font-size: 12px; color: var(--muted); text-align: center; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th { text-align: right; color: var(--muted); font-weight: 500; padding: 6px 0; border-bottom: 1px solid var(--rule-soft); }
.tbl th:first-child, .tbl td:first-child { text-align: left; font-family: var(--sans); }
.tbl td { text-align: right; padding: 7px 0; border-bottom: 1px solid var(--rule-soft); font-family: var(--mono); }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tile { border-radius: 14px; padding: 12px 14px; background: var(--card); border: 1px solid var(--rule); border-left-width: 1px; display: flex; flex-direction: column; gap: 4px; }
.tile .k { font-size: 12px; display: flex; align-items: center; gap: 6px; }
.tile .k i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tile .v { font-family: var(--mono); font-size: 16px; font-weight: 600; }

/* 더보기 */
.menu-list { display: flex; flex-direction: column; }
.menu-list .mi { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 52px; border-bottom: 1px solid var(--rule-soft); font-size: 14px; }
.menu-list .mi:last-child { border-bottom: 0; }
.cat-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 10px; border-radius: 18px; border: 1px solid var(--rule); background: var(--card); font-size: 13px; cursor: pointer; }
.cat-chip i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.cat-chip.hidden { opacity: .45; text-decoration: line-through; }

.foot { padding: 22px 20px 26px; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--rule-soft); margin-top: 8px; }
.foot-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.foot .ver { font-weight: 600; }
.foot .visits { font-weight: 700; letter-spacing: .02em; color: #3F433D; }
.foot .visits b { margin: 0 10px 0 4px; color: var(--ink); }
.foot .visits b.today { color: var(--inc); }
.foot .visits b:last-child { margin-right: 0; }
.foot-note { margin: 0; line-height: 1.6; }
.made { display: inline-flex; align-items: center; gap: 8px; color: #3F433D; text-decoration: none; font-size: 14px; min-height: 32px; align-self: flex-start; }
.made img { border-radius: 6px; }
.made b { font-weight: 700; letter-spacing: .02em; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 40; max-width: 90vw; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); }
.loading { padding: 40px 0; text-align: center; color: var(--muted); }
:focus-visible { outline: 2px solid var(--inc); outline-offset: 2px; }

/* 관리 */
.status { display: flex; flex-direction: column; }
.status .st { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; border-bottom: 1px solid var(--rule-soft); font-size: 14px; }
.status .st:last-child { border-bottom: 0; }
.pill { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 3px 9px; white-space: nowrap; }
.pill.ok { background: #E2EEDF; color: #2F5E26; }
.pill.no { background: #FFF1E4; color: #8A3F0A; }
.pill.wait { background: var(--rule-soft); color: #3F433D; }
.note-item { border-bottom: 1px solid var(--rule-soft); padding: 10px 0; display: flex; flex-direction: column; gap: 4px; }
.note-item:last-child { border-bottom: 0; }
.note-item .h { display: flex; align-items: baseline; gap: 8px; }
.note-item .v { font-family: var(--mono); font-weight: 600; }
.note-item .b { font-size: 13px; line-height: 1.6; color: #3F433D; white-space: pre-line; }
textarea.input { min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
