/* ==========================================================================
   나의 가계부 — 레트로 OS 테마
   아가일 체크 바탕 + 검은 테두리 창 + 파스텔 민트/페리윙클
   ========================================================================== */
/* 세종글꽃체 — 프로젝트 안에 넣어둔 파일을 씁니다 (static/fonts/) */
@font-face {
  font-family: 'SejongGeulggot';
  src: url('/fonts/SejongGeulggot.woff2') format('woff2'),
       url('/fonts/SejongGeulggot.woff')  format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  /* 바탕 */
  --bg:     #d7e0f6;
  --bg-2:   #eaeffc;
  --bg-3:   #ffffff;

  /* 창 */
  --win:    #ffffff;
  --bar:    #d7ead0;      /* 타이틀바 연두 */
  --bar-2:  #bedcb0;
  --btn:    #dcecd2;      /* 버튼 연두 */
  --btn-h:  #ecf6e6;

  /* 강조 */
  --blue:    #8ba9e0;
  --blue-lt: #c9d7f4;
  --blue-3:  #eaf0fd;
  --blue-dk: #5872b8;
  --yellow:  #fdf2c4;
  --pink:    #f6c3d0;
  --mint:    #bfe6d3;
  --lav:     #dad3f2;
  --peach:   #fbd9bd;

  --ink:   #1a1a1a;
  --muted: #79839c;
  --line:  #c9d2e8;

  --plus:  #2e8b62;
  --minus: #d1547a;

  /* 글씨체는 세종글꽃체 하나로 통일 */
  --font: 'SejongGeulggot', 'Malgun Gothic', sans-serif;
  --font-mono: 'SejongGeulggot', 'Malgun Gothic', sans-serif;

  --bd: 2px solid var(--ink);
  --pop: 3px 3px 0 var(--ink);
  --pop-sm: 2px 2px 0 var(--ink);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: var(--font);
  font-size: 15px;
  color: var(--ink);
}

/* 아가일 체크 바탕 */
body {
  background-color: var(--bg);
  background-image:
    repeating-linear-gradient(45deg,
      transparent 0 34px, rgba(255,255,255,.62) 34px 68px),
    repeating-linear-gradient(-45deg,
      transparent 0 34px, rgba(255,255,255,.62) 34px 68px),
    repeating-linear-gradient(45deg,
      transparent 0 66px, rgba(255,255,255,.85) 66px 68px),
    repeating-linear-gradient(-45deg,
      transparent 0 66px, rgba(255,255,255,.85) 66px 68px);
  background-attachment: fixed;
}

button, input, select, textarea {
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink);
}

/* ==========================================================================
   공통 부품 — 입력칸 / 버튼 / 창
   ========================================================================== */
.pxl-input {
  width: 100%; padding: 5px 9px;
  background: var(--win);
  border: var(--bd);
  border-radius: 0;
  outline: none;
}
.pxl-input:focus { box-shadow: inset 0 0 0 2px var(--blue); }
.pxl-input::placeholder { color: #a3abc2; }
textarea.pxl-input { resize: vertical; line-height: 1.5; }
select.pxl-input { cursor: pointer; }

.pxl-btn {
  padding: 5px 16px; cursor: pointer;
  background: var(--btn);
  border: var(--bd);
  border-radius: 0;
  box-shadow: var(--pop-sm);
  font-weight: 700; letter-spacing: -.2px;
  transition: transform .06s, box-shadow .06s, background .1s;
}
.pxl-btn:hover { background: var(--btn-h); }
.pxl-btn:active { transform: translate(2px, 2px); box-shadow: none; }
.pxl-btn:disabled { opacity: .45; cursor: default; }
.pxl-btn-lg { width: 100%; margin-top: 12px; padding: 10px; font-size: 16px; background: var(--blue-lt); }
.pxl-btn-lg:hover { background: var(--blue-3); }
.pxl-btn.tiny { padding: 3px 10px; font-size: 13px; }
.pxl-btn.wide { width: 100%; margin-top: 10px; }
.pxl-btn.ghost { background: var(--win); }
.pxl-btn.save { background: var(--blue-lt); }

/* ==========================================================================
   로그인 — 브라우저 창 모양
   ========================================================================== */
/* 화면 높이에 맞춰 줄어들도록 — 어떤 창 크기에서도 스크롤이 생기지 않게.
   장식이 화면 밖으로 삐져나가도 스크롤이 생기지 않게 html 까지 잠근다. */
html:has(> body.login-body) { overflow: hidden; height: 100%; }

.login-body {
  display: grid; place-items: center;
  min-height: 100vh; min-height: 100dvh;
  font-family: var(--font);
  padding: 14px;
  overflow: hidden;
}

.login-wrap {
  position: relative;
  width: min(520px, 94vw);
  animation: pop-in .28s ease-out;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(10px) } }

/* 창 위쪽 주소 표시줄 */
.login-urlbar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  background: var(--bar);
  border: var(--bd);
  border-bottom: none;
  font-family: var(--font-mono); font-size: 13px;
}
.login-urlbar .url {
  flex: 1; padding: 3px 10px;
  background: var(--win);
  border: var(--bd);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.login-urlbar .globe { font-size: 15px; }
.login-urlbar .back {
  width: 24px; height: 24px; flex: none;
  display: grid; place-items: center;
  background: var(--win); border: var(--bd);
}

.login-win {
  padding: clamp(14px, 3.2vh, 30px) 26px clamp(12px, 2.6vh, 26px);
  background: var(--win);
  border: var(--bd);
  box-shadow: 5px 5px 0 var(--ink);
  text-align: center;
}

/* 제목 자리 — 이미지를 그대로 넣는다 (정사각형 원본).
   화면이 낮으면 그림이 먼저 줄어들어 창 전체가 화면 안에 들어온다. */
.login-title {
  display: block;
  width: min(290px, 38vh); max-width: 100%;
  margin: 0 auto clamp(10px, 2.4vh, 20px);
  font-size: 0;              /* 대체 텍스트가 새어 나오지 않게 */
}
.login-title img {
  display: block;
  width: 100%; height: auto;
  border: var(--bd);         /* 배경색이 있는 그림이라 테두리를 둘러 창에 앉힌다 */
}

.login-form { margin: 0; }

/* 비밀번호 입력칸 */
.pw-pill {
  display: flex; align-items: stretch;
  width: min(360px, 100%); margin: 0 auto;
  background: var(--win);
  border: var(--bd);
  box-shadow: var(--pop);
}
.pw-pill.on { box-shadow: var(--pop), inset 0 0 0 2px var(--blue); }

.pw-badge {
  flex: none; width: 38px;
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 15px; font-weight: 700;
  background: var(--bar);
  border-right: var(--bd);
}

.pw-pill input {
  flex: 1; min-width: 0;
  border: none; outline: none; background: none;
  padding: 9px 11px;
  font-family: var(--font); font-size: 15px; font-weight: 600;
  letter-spacing: -.2px;
}
.pw-pill input::placeholder { color: var(--muted); font-weight: 500; }

.pw-go {
  flex: none; width: 42px;
  border: none; border-left: var(--bd); cursor: pointer;
  font-size: 15px; background: var(--btn);
}
.pw-go:hover { background: var(--btn-h); }
.pw-go:active { background: var(--bar-2); }

.login-msg {
  min-height: 18px; margin: clamp(8px, 1.6vh, 14px) 0 0;
  font-family: var(--font-mono); font-size: 12px; color: var(--muted);
}
.login-msg.err { color: var(--minus); }
.login-msg.ok  { color: var(--plus); }

.login-hello {
  margin: clamp(12px, 2.8vh, 24px) 0 0;
  font-size: clamp(17px, 2.6vh, 22px); font-weight: 800; letter-spacing: 1px;
}
.login-foot {
  margin: 4px 0 0;
  font-family: var(--font-mono); font-size: 11px; color: var(--muted);
  letter-spacing: .5px;
}

/* 창 바깥 장식들 */
.login-deco { position: absolute; inset: -70px -90px; pointer-events: none; z-index: -1; }
.login-deco > * { position: absolute; }

.deco-bar {
  /* 창 바로 위에 붙여 화면 위쪽에서 잘리지 않게 */
  top: 40px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 12px;
}
.deco-bar .track {
  display: block; width: 190px; height: 18px; padding: 2px;
  background: var(--win); border: var(--bd); border-radius: 999px;
}
.deco-bar .fill {
  display: block; width: 0%; height: 100%; border-radius: 999px;
  background: repeating-linear-gradient(90deg,
    var(--blue) 0 6px, transparent 6px 8px);
  transition: width .9s ease-out;
}
.deco-folder {
  bottom: 40px; right: -30px;
  width: 62px; height: 46px;
  background: var(--yellow); border: var(--bd);
  border-radius: 0 5px 5px 5px;
}
.deco-folder::before {
  content: ''; position: absolute; top: -10px; left: -2px;
  width: 30px; height: 12px;
  background: var(--yellow);
  border: var(--bd); border-bottom: none;
  border-radius: 4px 4px 0 0;
}
.deco-mail {
  bottom: -20px; left: -20px; font-size: 30px;
}
.deco-smiles {
  bottom: 6px; right: 40px;
  font-family: var(--font-mono); font-size: 15px; letter-spacing: 3px; color: var(--blue-dk);
}
.deco-wave { width: 76px; height: 22px; opacity: .95; }
.deco-wave.w1 { top: -30px; left: -66px; }
.deco-wave.w2 { bottom: 60px; left: -76px; }
.deco-wave.w3 { top: 90px; right: -74px; }

.shake { animation: shake .3s ease-in-out; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-7px)} 75%{transform:translateX(7px)} }

/* 좁거나 낮은 화면에서는 장식을 숨겨 창만 깔끔하게 보이도록 */
@media (max-width: 860px), (max-height: 640px) { .login-deco { display: none; } }

/* ==========================================================================
   상단 바
   ========================================================================== */
.app-body { min-height: 100%; padding-bottom: 30px; }

.desk-deco { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.desk-deco .deco { position: absolute; font-size: 22px; opacity: .5; color: var(--blue); }
.deco.d1 { top: 16%; left: 3%; }  .deco.d2 { top: 74%; left: 5%; }
.deco.d3 { top: 24%; right: 2.5%; } .deco.d4 { top: 84%; right: 4%; }

.topbar {
  position: relative; z-index: 3;
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 6px 16px;
  background: var(--bar);
  border-bottom: var(--bd);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
.pxl-logo { font-family: var(--font-mono); font-size: 15px; font-weight: 700; letter-spacing: -.5px; }
.topbar-user { font-size: 13px; color: #4c5570; }
.today-chip {
  font-family: var(--font-mono); font-size: 12px; padding: 2px 9px;
  background: var(--win); border: var(--bd);
}
.topbar .pxl-btn { background: var(--win); font-family: var(--font-mono); }

/* ==========================================================================
   창 탭
   ========================================================================== */
.book-stage {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center;
  padding: 18px 14px 0;
}

.tabs {
  display: flex; align-items: flex-end;
  width: min(1330px, 96vw);
  padding-left: 16px;
  gap: 4px;
}

.tab {
  position: relative;
  padding: 5px 18px 6px;
  cursor: pointer;
  font-size: 14px; font-weight: 700; letter-spacing: -.3px;
  background: var(--bg-2);
  border: var(--bd);
  border-bottom: none;
  border-radius: 0;
}
.tab:nth-child(1) { background: var(--bar); }
.tab:nth-child(2) { background: var(--blue-lt); }
.tab:nth-child(3) { background: var(--pink); }
.tab:nth-child(4) { background: var(--mint); }
.tab:nth-child(5) { background: var(--peach); }
.tab:nth-child(6) { background: var(--lav); }
.tab:hover { filter: brightness(1.05); }
.tab.active {
  padding-bottom: 9px; margin-bottom: -2px; z-index: 5;
  background: var(--win);
}

/* ==========================================================================
   본문 창
   ========================================================================== */
.book-row {
  display: flex; align-items: flex-start; justify-content: center;
  gap: 8px; width: 100%;
}

.book {
  position: relative; flex: 0 1 auto;
  width: min(1330px, 96vw);
  min-height: 620px;
  display: flex; flex-direction: column;
  perspective: 2200px;
  background: var(--win);
  border: var(--bd);
  box-shadow: 5px 5px 0 var(--ink);
}

/* 창 제목 줄 */
.win-bar {
  display: flex; align-items: center; gap: 8px;
  flex: none; padding: 5px 8px;
  background: var(--bar);
  border-bottom: var(--bd);
  font-family: var(--font-mono); font-size: 13px;
}
.win-bar .globe { font-size: 14px; }
.win-title {
  flex: 1; padding: 2px 10px;
  background: var(--win); border: var(--bd);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.win-btns { display: flex; gap: 4px; }
.win-btns b {
  width: 21px; height: 21px; font-weight: 400; font-size: 11px;
  display: grid; place-items: center;
  background: var(--win); border: var(--bd);
}

.book-spine { display: none; }

.spread { display: flex; width: 100%; flex: 1; }
.spread[hidden] { display: none; }

.page {
  flex: 1 1 50%; min-width: 0; padding: 16px 18px 22px;
  overflow-y: auto; max-height: 72vh;
}
.page-left { border-right: var(--bd); }

.page::-webkit-scrollbar { width: 14px; }
.page::-webkit-scrollbar-track { background: var(--bg-2); border-left: var(--bd); }
.page::-webkit-scrollbar-thumb { background: var(--blue-lt); border: var(--bd); }

.page-title {
  font-size: 21px; font-weight: 800; letter-spacing: -.6px;
  margin: 0 0 12px; padding: 3px 12px;
  display: block; width: max-content; max-width: 100%;
  background: var(--bar);
  border: var(--bd);
  box-shadow: var(--pop-sm);
}
.page-title.no-mb { margin: 0; }

.sub-title {
  font-size: 14px; font-weight: 700; margin: 16px 0 6px;
  display: block; width: max-content; max-width: 100%;
  padding: 2px 10px;
  background: var(--blue-lt);
  border: var(--bd);
}
.sub-title.in-title  { background: var(--mint); }
.sub-title.out-title { background: var(--pink); }

/* 넘김 화살표 */
.page-arrow {
  position: sticky; top: 42vh; align-self: center;
  width: 28px; height: 46px; cursor: pointer; font-size: 12px;
  background: var(--btn);
  border: var(--bd);
  box-shadow: var(--pop-sm);
}
.page-arrow:hover { background: var(--btn-h); }
.page-arrow:active { transform: translate(2px,2px); box-shadow: none; }
.page-arrow:disabled { opacity: .35; cursor: default; }

/* ==========================================================================
   리스트 · 게이지
   ========================================================================== */
.mini-list, .tx-list, .unres-list, .rule-list { list-style: none; margin: 6px 0 0; padding: 0; }

.mini-list li {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 13px; padding: 3px 2px;
  border-bottom: 1px dashed var(--line);
}
.mini-list li span:last-child { white-space: nowrap; font-family: var(--font-mono); font-size: 12px; }

.gauge-label { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; }
.pxl-gauge {
  height: 16px; padding: 2px;
  background: var(--win); border: var(--bd); border-radius: 999px;
}
.pxl-gauge-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: repeating-linear-gradient(90deg, var(--pink) 0 7px, var(--win) 7px 9px);
  transition: width .35s ease;
}
.pxl-gauge-fill.mint { background: repeating-linear-gradient(90deg, var(--blue) 0 7px, var(--win) 7px 9px); }
.pxl-gauge-fill.over { background: repeating-linear-gradient(90deg, #e07b9c 0 7px, var(--win) 7px 9px); }

.empty { font-size: 13px; color: var(--muted); padding: 10px 2px; }
.tx-list li.empty {
  display: block; background: var(--bg-2); box-shadow: none; text-align: center;
  border: 2px dashed var(--line); padding: 14px 8px;
}

.icon-btn {
  border: none; background: none; cursor: pointer; color: var(--muted);
  font-size: 14px; padding: 2px 4px; line-height: 1;
}
.icon-btn:hover { color: var(--minus); }

/* ==========================================================================
   폼
   ========================================================================== */
.stack-form { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.row > * { flex: 1 1 0; min-width: 88px; }
.row > .flex { flex: 3 1 0; }
.inline-form { display: flex; gap: 6px; margin-top: 8px; align-items: stretch; }
.inline-form .pxl-btn { flex: none; white-space: nowrap; }
.inline-form .pxl-input { flex: 1 1 auto; min-width: 0; }
.inline-form select.pxl-input { flex: 0 0 auto; width: auto; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.chk input { accent-color: var(--blue-dk); width: 14px; height: 14px; }
.hint { font-size: 12px; color: var(--muted); min-height: 16px; margin: 4px 0 0; line-height: 1.5; }
.mid-label { flex: 0 0 auto !important; min-width: 0 !important; font-size: 13px; align-self: center; }
.opt-checks { display: flex; flex-direction: column; gap: 3px; margin-top: 8px; text-align: left; }

/* ==========================================================================
   가계부
   ========================================================================== */
.upload-box {
  text-align: center; padding: 14px; margin-bottom: 10px;
  background: var(--blue-3);
  border: 2px dashed var(--blue);
}
.upload-box.drag { background: var(--mint); border-color: var(--plus); }
.upload-icon { font-size: 26px; }
.upload-text { font-size: 13px; line-height: 1.5; margin: 2px 0 9px; color: var(--muted); }
.upload-opt { margin-top: 8px; align-items: center; }

.import-report { font-size: 12px; line-height: 1.55; margin-bottom: 6px; }
.import-report .rep {
  background: var(--blue-3); border: var(--bd); padding: 8px 10px;
  box-shadow: var(--pop-sm);
}
.import-report .rep.err { background: #fdeaf0; }
.import-report ul { margin: 4px 0 0; padding-left: 16px; }

.ledger-head { display: flex; align-items: center; justify-content: space-between; }
.count-chip {
  font-family: var(--font-mono); font-size: 12px; padding: 1px 9px;
  background: var(--blue-lt); border: var(--bd);
}
.count-chip.pink { background: var(--pink); }

.ledger-sum { display: flex; gap: 6px; margin: 10px 0; font-size: 13px; }
.ledger-sum div {
  flex: 1; text-align: center; padding: 5px 4px;
  border: var(--bd); box-shadow: var(--pop-sm);
}
.ledger-sum .s-in  { background: var(--mint); }
.ledger-sum .s-out { background: var(--pink); }
.ledger-sum .s-net { background: var(--blue-lt); }
.ledger-sum b { font-family: var(--font-mono); font-size: 13px; }

.tx-list li {
  display: grid; grid-template-columns: 56px 1fr auto auto auto;
  gap: 8px; align-items: center; font-size: 13px;
  padding: 5px 9px; margin-bottom: 4px;
  background: var(--win);
  border: var(--bd);
}
.tx-list li.income  { border-left: 6px solid var(--mint); }
.tx-list li.expense { border-left: 6px solid var(--pink); }
.tx-list li.ex { opacity: .55; background: var(--bg-2); }
.tx-list li.ex .tx-content { text-decoration: line-through; }
.tx-date { font-family: var(--font-mono); font-size: 10px; color: var(--muted); line-height: 1.35; white-space: nowrap; }
.tx-main { min-width: 0; }
.tx-content { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-meta { font-size: 11px; color: var(--muted); }
.tx-cat {
  display: inline-block; padding: 0 6px; margin-right: 4px; font-size: 11px;
  background: var(--bar); border: 1px solid var(--ink);
}
.tx-amount { font-family: var(--font-mono); font-size: 13px; white-space: nowrap; font-weight: 700; }
.tx-amount.minus { color: var(--minus); }
.tx-amount.plus  { color: var(--plus); }
.tx-badge {
  display: inline-block; font-size: 10px; padding: 0 5px; margin-left: 4px;
  background: var(--muted); color: #fff;
}

/* ==========================================================================
   붙여넣기
   ========================================================================== */
.paste-area {
  margin-top: 5px; font-family: var(--font-mono); font-size: 12px; line-height: 1.45;
  white-space: pre; overflow-x: auto;
}
.paste-preview { font-size: 13px; line-height: 1.45; margin-top: 8px; }
.paste-preview .pp {
  background: var(--blue-3); border: var(--bd); padding: 8px 10px;
  box-shadow: var(--pop-sm);
}
.paste-preview .pp.ok  { background: var(--mint); }
.paste-preview .pp.err { background: #fdeaf0; }
.paste-preview .pxl-btn { margin-top: 8px; width: 100%; }

.pp-table {
  max-height: 200px; overflow: auto; margin-top: 8px;
  background: var(--win); border: var(--bd);
}
.pp-table table { border-collapse: collapse; width: 100%; font-size: 12px; }
.pp-table th {
  position: sticky; top: 0; background: var(--bar);
  border-bottom: var(--bd); padding: 3px 6px; font-weight: 700;
}
.pp-table td { border-bottom: 1px dashed var(--line); padding: 2px 6px; white-space: nowrap; }
.pp-table td.num { text-align: right; font-family: var(--font-mono); }
.pp-table td.uncat { background: #fdeaf0; }
.pp-table tr.dup { opacity: .45; text-decoration: line-through; }
.pp-table .more { padding: 4px; text-align: center; color: var(--muted); font-size: 11px; }

/* ==========================================================================
   시트
   ========================================================================== */
.spread.full .page { flex: 1 1 100%; border-right: none; max-height: 74vh; }

.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin-bottom: 9px;
}
.sheet-actions { display: flex; align-items: center; gap: 6px; }
.dirty-chip {
  font-family: var(--font-mono); font-size: 12px; padding: 2px 10px;
  background: var(--win); border: var(--bd);
}
.dirty-chip.on { background: var(--yellow); }

.sheet-toolbar, .sheet-bulk {
  display: flex; gap: 5px; flex-wrap: wrap; align-items: center;
  padding: 6px 8px; margin-bottom: 7px;
  border: var(--bd);
}
.sheet-toolbar { background: var(--bg-2); }
.sheet-bulk { background: var(--yellow); font-size: 13px; }
.sheet-toolbar .pxl-input, .sheet-bulk .pxl-input {
  flex: 0 0 auto; width: auto; font-size: 12px; padding: 2px 7px;
}
.sheet-toolbar .pxl-input.grow { flex: 1 1 150px; }

.sheet-wrap {
  overflow: auto; max-height: 48vh;
  background: var(--win); border: var(--bd);
}
table.sheet {
  border-collapse: collapse; width: 100%; min-width: 1150px;
  table-layout: fixed; font-size: 13px;
}
table.sheet th {
  position: sticky; top: 0; z-index: 2;
  background: var(--bar);
  border-bottom: var(--bd); border-right: 1px solid var(--ink);
  padding: 4px; font-weight: 700; white-space: nowrap; font-size: 12px;
}
table.sheet td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 0; }
table.sheet tr:hover td { background: var(--blue-3); }
table.sheet tr.ex td { background: var(--bg-2); color: var(--muted); }
table.sheet tr.ex .cell { text-decoration: line-through; }
table.sheet tr.sel td { background: var(--yellow); }
table.sheet tr.uncat .c-cat .cell { background: #fdeaf0; }

.sheet .cell {
  width: 100%; border: none; background: transparent; padding: 3px 5px;
  font-family: var(--font); font-size: 13px; color: var(--ink);
}
.sheet .cell:focus { outline: none; background: var(--win); box-shadow: inset 0 0 0 2px var(--blue); }
.sheet .cell.dirty { background: var(--yellow); }
.sheet .cell.num { text-align: right; font-family: var(--font-mono); }
.sheet select.cell { cursor: pointer; }

.c-chk, .c-ex { width: 32px; text-align: center; }
.c-no { width: 34px; text-align: center; color: var(--muted); font-size: 11px; }
.c-date { width: 126px; }  .c-time { width: 122px; }
.c-type { width: 68px; }   .c-cat { width: 104px; }
.c-content { width: 178px; }
.c-amount { width: 92px; } .c-target { width: 62px; }
.c-method { width: 152px; } .c-memo { width: 130px; }
td.c-no { text-align: center; color: var(--muted); font-family: var(--font-mono); font-size: 11px; padding: 4px; }
td.c-chk, td.c-ex { text-align: center; padding: 3px; }
td.c-chk input, td.c-ex input { accent-color: var(--blue-dk); width: 14px; height: 14px; }

/* 분류 탭 — 배운 규칙 확인 목록 */
.learned-box { margin-bottom: 12px; }
.learn-list { list-style: none; margin: 6px 0 0; padding: 0; }
.learn-list li {
  padding: 7px 10px; margin-bottom: 5px;
  background: #fdeaf0; border: var(--bd);
}
.learn-head { font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.learn-head select { width: auto; flex: 0 0 auto; font-size: 12px; padding: 1px 6px; }
.learn-meta { font-size: 11px; color: var(--muted); margin: 3px 0 5px; line-height: 1.4; }
.learn-act { display: flex; gap: 5px; align-items: center; }
.learn-act .learn-pat { flex: 1; font-size: 12px; padding: 2px 7px; }

/* 배운 규칙이 자동으로 붙인 소분류 — 한 번 더 확인할 것 */
table.sheet tr.check td { background: #fdeaf0; }
table.sheet tr.check .c-cat .cell { box-shadow: inset 0 0 0 2px var(--minus); }

/* 시트 — 휴지통 */
.trash-chip {
  font-size: 11px; padding: 0 5px; margin-left: 3px;
  color: var(--muted);
}
.trash-chip.on { background: var(--pink); color: var(--ink); border: 1px solid var(--ink); }
.icon-btn.back { color: var(--plus); font-weight: 700; }
.icon-btn.back:hover { color: #fff; background: var(--plus); }

/* 시트 — 한 줄 지우기 */
#sheet-table .c-del { width: 42px; text-align: center; }
td.c-del { text-align: center; padding: 2px; }
.icon-btn.del { color: var(--muted); font-weight: 700; }
.icon-btn.del:hover { color: #fff; background: var(--minus); }

/* 되돌릴 수 없는 동작은 눈에 띄게 */
.pxl-btn.danger { background: var(--pink); }
.pxl-btn.danger:hover { background: #f7a7bb; }

.sheet-foot {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px; font-family: var(--font-mono); font-size: 12px;
}

/* 예산 · 자동이체 표 위의 합계 띠 */
.sum-strip {
  display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 9px;
}
.sum-cell {
  flex: 1 1 130px; min-width: 130px;
  padding: 5px 10px 7px;
  background: var(--bg-2); border: var(--bd); box-shadow: var(--pop-sm);
}
.sum-cell.big { background: var(--bar); }
.sum-cell.wide { flex: 2 1 260px; }
.sum-cell > span { display: block; font-size: 12px; color: var(--muted); }
.sum-cell > b { font-family: var(--font-mono); font-size: 17px; }
.sum-cell > em { font-style: normal; font-size: 11px; color: var(--muted); margin-left: 5px; }
.sum-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.sum-list i {
  font-style: normal; font-size: 11px; padding: 0 6px;
  background: var(--win); border: 1px solid var(--ink);
}
.sum-list i b { font-family: var(--font-mono); }

/* ==========================================================================
   돈주머니
   ========================================================================== */
.goal-box {
  padding: 7px 11px 8px; margin-bottom: 4px;
  background: var(--bg-2); border: var(--bd); box-shadow: var(--pop-sm);
}
.goal-nums { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.goal-nums b { font-family: var(--font-mono); font-size: 22px; line-height: 1; }
.goal-nums span { font-size: 12px; color: var(--muted); }
.pxl-gauge.big { height: 13px; }
.goal-legend {
  display: flex; justify-content: space-between; gap: 10px;
  margin-top: 4px; font-size: 12px; color: var(--muted);
}
.goal-legend b { font-family: var(--font-mono); color: var(--ink); margin-left: 3px; }

/* 정사각형 그래프 + 범례를 나란히 (범례는 그래프 옆에 붙여 좁게) */
.tree-row {
  display: flex; align-items: flex-start; gap: 10px; margin: 6px 0 4px;
}
#pk-tree {
  display: block; flex: 0 0 auto;
  width: 250px; max-width: 52%; aspect-ratio: 1 / 1; height: auto;
}
#pk-legend {
  flex: 0 1 auto; width: 215px; min-width: 150px; max-width: 240px;
  font-size: 13px;
}
#pk-legend li.pick {
  display: block; cursor: pointer; padding: 2px 5px; margin-bottom: 1px;
  border: 2px solid transparent; line-height: 1.35;
}
#pk-legend li.pick:hover { background: var(--butter-3); }
#pk-legend li.pick.on { border-color: var(--ink); background: var(--butter); }
#pk-legend .sw { display: inline-block; vertical-align: -1px; margin-right: 5px; }
#pk-legend .lg-name { display: inline; }
#pk-legend .lg-val {
  display: block; font-size: 11px; margin-left: 18px; text-align: left;
}

/* 목표 설정 — 한 줄로 */
.goal-form {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px;
}
.goal-form #pk-goal { flex: 1 1 120px; min-width: 0; }
.goal-form #pk-goal-cats { flex: 1 1 110px; min-width: 0; }
.goal-form .chk { flex: 0 0 auto; font-size: 12px; }
.goal-form .pxl-btn { flex: 0 0 auto; }
.goal-form .hint { flex: 1 1 100%; min-height: 0; margin: 0; }
.goal-form .hint:empty { display: none; }

.pocket-detail { list-style: none; margin: 8px 0 0; padding: 0; }
.pocket-detail li {
  display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center;
  padding: 5px 10px; margin-bottom: 4px; font-size: 14px;
  background: var(--win); border: var(--bd);
}
.pocket-detail .pd-kind { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pocket-detail .pd-due {
  font-family: var(--font-mono); font-size: 11px; color: var(--muted);
  padding: 0 7px; background: var(--blue-3); border: 1px solid var(--line); white-space: nowrap;
}
.pocket-detail .pd-amt { font-family: var(--font-mono); font-weight: 700; white-space: nowrap; }
.pocket-detail li.empty { display: block; background: var(--bg-2); border: 2px dashed var(--line); text-align: center; }

/* 화면이 낮으면 표가 먼저 줄어들어 한 페이지에 담긴다 */
.sheet-wrap.short { max-height: min(240px, 25vh); }
.sub-title.no-mb { margin-bottom: 0; }
.c-due { width: 118px; }
/* 돈주머니 표는 오른쪽 반쪽에 들어가므로 열을 좁게 */
#pk-table { min-width: 0; }
#pk-table .c-detail { width: 150px; }
#pk-table .c-due { width: 104px; }
#pk-table .c-cat2 { width: 92px; }
/* 투자 탭과 연결된 줄 */
#pk-table tr.linked td { background: var(--blue-3); }
.sheet .cell.locked { color: var(--muted); cursor: not-allowed; }
.link-tag {
  font-size: 10px; padding: 0 4px; margin-left: 4px;
  background: var(--blue-lt); border: 1px solid var(--ink); white-space: nowrap;
}

/* ==========================================================================
   투자 — 계좌 × 관리자 교차표
   ========================================================================== */
.sum-cell.full { flex: 1 1 100%; }
table.matrix {
  border-collapse: collapse; margin-top: 4px; font-size: 13px;
  background: var(--win);
}
table.matrix th, table.matrix td {
  border: 1px solid var(--ink); padding: 2px 12px; text-align: right;
  white-space: nowrap;
}
table.matrix thead th { background: var(--bar); font-weight: 700; text-align: center; }
table.matrix tbody th { background: var(--blue-3); text-align: left; font-weight: 700; }
table.matrix td { font-family: var(--font-mono); }
table.matrix .mt-tot { background: var(--butter-3); font-weight: 700; }
table.matrix tr.mt-foot th, table.matrix tr.mt-foot td { background: var(--butter); font-weight: 700; }

.c-owner  { width: 72px; }
.c-acct2  { width: 118px; }
.c-type   { width: 88px; }
.c-name   { width: 210px; }
.c-ticker { width: 130px; }
.c-shares { width: 78px; }
.c-price  { width: 84px; }
.c-rate   { width: 68px; }
#hd-table { min-width: 1030px; }
#hd-table tr.warn td { background: #fdeaf0; }

.price-chip {
  font-family: var(--font-mono); font-size: 12px; padding: 2px 9px;
  background: var(--win); border: var(--bd); color: var(--muted);
}
.price-chip.on { background: var(--blue-3); color: var(--ink); }

.warn-tag {
  display: block; font-size: 10px; color: var(--minus); line-height: 1.2;
  padding: 0 4px 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.price-note { font-size: 12px; margin-bottom: 7px; }
.price-note:empty { display: none; }
.price-note .pn {
  padding: 6px 10px; background: var(--blue-3); border: var(--bd);
}
.price-note .pn.err { background: #fdeaf0; }
.price-note .pn-warn { margin-top: 4px; color: var(--minus); line-height: 1.5; }

.sum-flags { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* 예산 · 자동이체 전용 열 폭 */
.c-period { width: 96px; }
.c-acct   { width: 150px; }
.c-cat2   { width: 120px; }
.c-card   { width: 100px; }
.c-detail { width: 300px; }
.c-payday { width: 78px; }
.c-del    { width: 44px; text-align: center; }
td.c-del  { text-align: center; padding: 2px; }
#bg-table, #au-table { min-width: 860px; }

/* ==========================================================================
   분류 · 규칙
   ========================================================================== */
.unres-list li {
  padding: 7px 10px; margin-bottom: 5px; font-size: 13px;
  background: var(--win); border: var(--bd);
}
.unres-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.unres-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.unres-meta { font-size: 11px; color: var(--muted); margin: 2px 0 5px; line-height: 1.4; }
.unres-act { display: flex; gap: 6px; align-items: center; }
.unres-act select { flex: 1; font-size: 12px; padding: 2px 7px; }

.rule-list li {
  display: flex; align-items: center; gap: 6px; font-size: 12px;
  padding: 3px 9px; margin-bottom: 3px;
  background: var(--win); border: var(--bd);
}
.rule-list li.off { opacity: .42; }
.rule-list li.builtin { background: var(--bg-2); }
.rule-list .r-pat { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rule-list .r-cat {
  padding: 0 7px; background: var(--mint);
  border: 1px solid var(--ink); white-space: nowrap; font-size: 11px;
}
.rule-list .r-meta { color: var(--muted); font-family: var(--font-mono); font-size: 10px; white-space: nowrap; }
.rule-list .r-hit { color: var(--minus); font-family: var(--font-mono); font-size: 10px; }

.pair-preview { font-size: 12px; margin-top: 10px; line-height: 1.5; }
.pair-preview .pp {
  background: var(--blue-3); border: var(--bd);
  padding: 8px 10px; max-height: 220px; overflow-y: auto;
}
.pair-preview .pp div { padding: 1px 0; border-bottom: 1px dashed var(--line); }

/* ==========================================================================
   통계
   ========================================================================== */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-head .page-title { font-family: var(--font-mono); font-size: 19px; }

.chart-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.pxl-donut { flex: none; width: 226px; height: 226px; }
.pxl-bars { width: 100%; height: 196px; margin-top: 4px; }

.legend { list-style: none; margin: 0; padding: 0; flex: 1 1 175px; min-width: 160px; font-size: 12px; }
.legend li { display: flex; align-items: center; gap: 6px; padding: 1px 0; }
.legend .sw { width: 12px; height: 12px; flex: none; border: 1px solid var(--ink); }
.legend .lg-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend .lg-val { color: var(--muted); white-space: nowrap; font-family: var(--font-mono); font-size: 11px; }

.total-line {
  margin-top: 8px; padding: 4px 10px; font-size: 13px;
  background: var(--bar); border: var(--bd); box-shadow: var(--pop-sm);
  display: flex; justify-content: space-between;
}
.total-line b { font-family: var(--font-mono); }
.legend-inline { display: flex; gap: 14px; font-size: 12px; margin-top: 4px; }
.legend-inline span { display: flex; align-items: center; gap: 5px; }
.dot { display: inline-block; width: 10px; height: 10px; border: 1px solid var(--ink); }
.dot.pink { background: var(--pink); } .dot.mint { background: var(--mint); }
.dot.sky { background: var(--blue); }  .dot.butter { background: var(--yellow); }

/* ==========================================================================
   내보내기
   ========================================================================== */
.export-summary {
  padding: 10px 14px 12px; margin-bottom: 12px;
  background: var(--bg-2); border: var(--bd); box-shadow: var(--pop);
}
.xs-big {
  font-family: var(--font-mono); font-size: 40px; font-weight: 700; line-height: 1;
  text-align: center; padding: 4px 0 10px;
}
.xs-big span { font-family: var(--font); font-size: 15px; margin-left: 4px; }
.sheet-desc li span:first-child { color: var(--ink); }

.guide { font-size: 12px; line-height: 1.6; }
.guide p { margin: 0 0 8px; }
.guide code {
  background: var(--blue-3); border: 1px solid var(--line);
  padding: 0 4px; font-family: var(--font-mono); font-size: 11px;
}

/* ==========================================================================
   토스트
   ========================================================================== */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(14px);
  padding: 7px 20px; font-size: 14px; font-weight: 700; z-index: 1000;
  background: var(--bar); border: var(--bd); box-shadow: var(--pop);
  opacity: 0; pointer-events: none;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); transition: all .18s ease-out; }
.toast.err { background: var(--pink); }

/* ==========================================================================
   좁은 화면
   ========================================================================== */
@media (max-width: 900px) {
  .book { min-height: 0; }
  .spread { flex-direction: column; }
  .page { max-height: none; }
  .page-left { border-right: none; border-bottom: var(--bd); }
  .tabs { flex-wrap: wrap; padding-left: 0; }
  .tab { padding: 4px 12px 6px; font-size: 13px; }
  .tab.active { margin-bottom: 0; }
  .book-row { flex-wrap: wrap; }
  .page-arrow { position: static; }
}
