/* =============================================
   울타리와공간 재정 관리 — Finance CSS
   admin 프로젝트 토큰 재사용 (2A6B67 teal 계열)
   ============================================= */

:root {
  --p:    #8B4A5C;
  --pd:   #5C2E3A;
  --pm:   #3D8480;
  --pl:   #F5E9EC;
  --pl2:  #C8E4E2;
  --acc:  #D4A373;
  --acc-l:#FAF0EA;
  --tg:   #7DCFCA;

  --txt:     #1A2B2A;
  --mut:     #667070;
  --fnt:     #9AABAB;
  --bg:      #F3F7F7;
  --bg-w:    #FFFFFF;
  --bg-dark: #162422;
  --brd:     #DDE8E8;

  --ok:     #1A7F5A;  --ok-bg:   #D4F0E4;
  --warn:   #9B4A0A;  --warn-bg: #FDECD8;
  --err:    #9B1A1A;  --err-bg:  #FDE8E8;
  --inf:    #1A4F7A;  --inf-bg:  #E0EEF6;
  --ai:     #5B21B6;  --ai-bg:   #EDE9FE;

  --sh:    0 1px 4px rgba(42,107,103,.07), 0 1px 2px rgba(42,107,103,.05);
  --sh-lg: 0 6px 24px rgba(42,107,103,.13);
  --radius:    10px;
  --radius-sm: 6px;
  --hdr:       52px;

  --font-serif: 'Noto Serif KR', serif;
  --font-sans:  'Noto Sans KR', sans-serif;
}

/* ── Reset ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--txt);
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
ul { list-style: none; }
button { cursor: pointer; font-family: var(--font-sans); }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: var(--brd); border-radius: 3px; }

/* ── Header ─────────────────────────────────── */
#hdr {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--hdr);
  background: #5C2E3A;
  display: flex; align-items: center;
  padding: 0 20px; gap: 14px;
  z-index: 300;
  box-shadow: 0 1px 0 rgba(255,255,255,.06), 0 2px 12px rgba(0,0,0,.25);
}
.hdr-logo {
  display: flex; flex-direction: column;
  line-height: 1.2; flex-shrink: 0;
  padding-right: 14px;
  border-right: 1px solid rgba(255,255,255,.1);
}
.hdr-logo-ko {
  font-family: var(--font-serif);
  font-size: 13px; font-weight: 700;
  color: #fff; letter-spacing: -.02em; white-space: nowrap;
}
.hdr-logo-sub {
  font-size: 9px; color: rgba(255,255,255,.35); letter-spacing: .05em;
}
.hdr-nav { display: flex; align-items: center; gap: 4px; flex: 1; }
.hdr-nav a {
  display: flex; align-items: center; gap: 6px;
  color: rgba(255,255,255,.58);
  font-size: 12.5px; font-weight: 500;
  padding: 6px 14px; border-radius: 100px;
  transition: all .15s; white-space: nowrap;
}
.hdr-nav a i { font-size: 14px; }
.hdr-nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.hdr-nav a.active { background: #8B4A5C; color: #fff; font-weight: 700; }

.hdr-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.hdr-user { font-size: 12px; color: rgba(255,255,255,.65); white-space: nowrap; }
.hdr-user strong { color: rgba(255,255,255,.82); font-weight: 600; }
.hdr-logout {
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.12);
  color: rgba(255,255,255,.55);
  font-size: 11.5px; font-weight: 500;
  padding: 4px 10px; border-radius: 100px;
  transition: all .15s;
}
.hdr-logout:hover { background: rgba(255,255,255,.14); color: #fff; }

/* 햄버거 버튼 (데스크톱에서는 숨김) */
.hdr-burger {
  display: none; flex-direction: column; justify-content: center; gap: 4px;
  width: 30px; height: 30px; background: none; border: none; padding: 0;
}
.hdr-burger span {
  display: block; width: 20px; height: 2px; background: rgba(255,255,255,.75);
  border-radius: 2px; transition: transform .2s, opacity .2s;
}
.hdr-burger.active span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hdr-burger.active span:nth-child(2) { opacity: 0; }
.hdr-burger.active span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ── 모바일 내비 드로어 ─────────────────────── */
.mnav-backdrop {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 290; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.mnav-backdrop.open { opacity: 1; pointer-events: auto; }
.mnav {
  display: none;
  position: fixed; top: var(--hdr); right: 0; bottom: 0;
  width: 240px; max-width: 78vw;
  background: var(--bg-dark);
  z-index: 295; padding: 10px;
  transform: translateX(100%);
  transition: transform .22s ease;
  overflow-y: auto;
}
.mnav.open { transform: translateX(0); }
.mnav a {
  display: block; padding: 13px 14px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.68); font-size: 14px; font-weight: 500;
}
.mnav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.mnav a.active { background: rgba(255,255,255,.16); color: #fff; font-weight: 700; }

/* ── Main ────────────────────────────────────── */
#app {
  padding-top: var(--hdr);
  min-height: 100vh;
}
.page-inner { padding: 22px 24px; max-width: 1400px; margin: 0 auto; }
.loading-full {
  display: flex; align-items: center; justify-content: center;
  height: calc(100vh - var(--hdr)); color: var(--mut); font-size: 14px;
}

/* ── Page Header ────────────────────────────── */
.ph { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 8px; }
.pt { font-family: var(--font-serif); font-size: 19px; font-weight: 700; color: var(--pd); }

/* ── Cards ──────────────────────────────────── */
.card {
  background: var(--bg-w); border: 1px solid var(--brd);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--sh);
}
.card + .card { margin-top: 12px; }
.card-title { font-size: 13px; font-weight: 700; color: var(--pd); margin-bottom: 14px; display: flex; align-items: center; gap: 7px; }

/* ── Stat Grid ──────────────────────────────── */
.sg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.sc {
  background: var(--bg-w); border: 1px solid var(--brd);
  border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--sh);
}
.sc-lbl { font-size: 10px; color: var(--mut); letter-spacing: .5px; text-transform: uppercase; margin-bottom: 6px; }
.sc-val { font-size: 24px; font-weight: 700; color: var(--p); letter-spacing: -1px; line-height: 1; }
.sc-sub { font-size: 11px; color: var(--fnt); margin-top: 3px; }

/* ── Tables (모바일에서 카드형으로 전환) ────────
   사용법: <div class="tw"><table>…<td data-label="이름">홍길동</td>…</table></div>
   768px 이하에서 각 tr 이 카드처럼 쌓이고, td 왼쪽에 data-label 이 라벨로 표시됨 */
.tw { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
thead th {
  background: #F3F7F7; text-align: left;
  padding: 8px 12px; font-weight: 700; font-size: 11px;
  color: var(--mut); border-bottom: 1.5px solid var(--brd); white-space: nowrap;
}
td { padding: 8px 12px; border-bottom: 1px solid #EBF2F7; vertical-align: middle; }
tr:hover td { background: #F6FAFA; }
tr:last-child td { border-bottom: none; }
.tbl-link { color: var(--p); cursor: pointer; font-weight: 600; }
.tbl-link:hover { text-decoration: underline; }

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 14px; border-radius: var(--radius-sm); border: none;
  font-size: 13px; font-family: var(--font-sans); font-weight: 600;
  transition: all .15s; white-space: nowrap; cursor: pointer; line-height: 1.4;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.bp  { background: var(--p);   color: #fff; }
.bp:hover:not(:disabled)  { background: var(--pd); }
.bs  { background: #fff;  color: var(--txt); border: 1.5px solid var(--brd); }
.bs:hover:not(:disabled)  { background: var(--bg); }
.bd  { background: var(--err-bg); color: var(--err); border: 1px solid #F5C6C6; }
.bd:hover:not(:disabled)  { background: #FACDCD; }
.sm { padding: 4px 9px;  font-size: 11.5px; border-radius: 5px; }

/* ── Forms ──────────────────────────────────── */
.fi { display: flex; flex-direction: column; gap: 4px; }
label { font-size: 10px; font-weight: 700; color: var(--mut); letter-spacing: .4px; text-transform: uppercase; }
input, select, textarea {
  border: 1.5px solid var(--brd); border-radius: var(--radius-sm);
  padding: 7px 10px; font-size: 13px; font-family: var(--font-sans);
  color: var(--txt); width: 100%; outline: none; background: #fff;
  transition: border .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--p); box-shadow: 0 0 0 3px rgba(42,107,103,.1);
}
.fg  { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fg3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ── Badges ─────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 10.5px; font-weight: 700; white-space: nowrap;
}
.bok   { background: var(--ok-bg);   color: var(--ok); }
.bwarn { background: var(--warn-bg); color: var(--warn); }
.berr  { background: var(--err-bg);  color: var(--err); }
.binf  { background: var(--inf-bg);  color: var(--inf); }
.bdef  { background: #F0F0F0;        color: #666; }

/* ── Misc ───────────────────────────────────── */
.muted { color: var(--mut); }
.faint { color: var(--fnt); }
.hidden { display: none !important; }

/* ── 부채 연동(유동지출 폼) ─────────────────────── */
.debt-new-fields { padding: 10px; border: 1px solid var(--brd); border-radius: 8px; }

/* ── Login page ─────────────────────────────── */
.login-body {
  background: var(--pd);
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-wrap { width: 100%; max-width: 380px; }
.login-card {
  background: #fff; border-radius: 16px; padding: 40px;
  box-shadow: 0 24px 60px rgba(0,0,0,.28);
}
.login-logo { text-align: center; margin-bottom: 30px; }
.login-logo-ko { display: block; font-family: var(--font-serif); font-size: 17px; font-weight: 700; color: var(--pd); margin-bottom: 5px; }
.login-logo-sub { display: block; font-size: 10.5px; color: var(--mut); letter-spacing: .05em; }
.login-divider { height: 1px; background: var(--brd); margin: 0 0 24px; }
.login-fi + .login-fi { margin-top: 12px; }
.login-fi label { display: block; font-size: 10px; font-weight: 700; color: var(--mut); letter-spacing: .4px; text-transform: uppercase; margin-bottom: 5px; }
.login-fi input { font-size: 14px; padding: 9px 12px; border-radius: 8px; }
.login-submit { width: 100%; margin-top: 18px; padding: 10px; font-size: 14px; border-radius: 8px; justify-content: center; }
.login-err { display: none; margin-top: 12px; padding: 8px 12px; background: var(--err-bg); color: var(--err); border-radius: 6px; font-size: 12.5px; line-height: 1.5; }

/* ── Responsive (768px 기준) ────────────────── */
@media (max-width: 768px) {
  .hdr-nav { display: none; }
  .hdr-burger { display: flex; }
  .mnav, .mnav-backdrop { display: block; }
  .hdr-user { display: none; }
  .page-inner { padding: 16px; }
  .sg { grid-template-columns: repeat(2, 1fr); }
  .fg, .fg3 { grid-template-columns: 1fr; }

  /* 표 → 카드 전환 */
  .tw table, .tw thead, .tw tbody, .tw th, .tw td, .tw tr { display: block; }
  .tw thead tr { position: absolute; top: -9999px; left: -9999px; }
  .tw tbody tr {
    margin-bottom: 10px; border: 1px solid var(--brd);
    border-radius: var(--radius-sm); padding: 4px 0; background: #fff;
  }
  .tw tbody td {
    border: none; position: relative; padding: 7px 12px 7px 46%;
    text-align: right; min-height: 30px;
  }
  .tw tbody td::before {
    content: attr(data-label);
    position: absolute; left: 12px; top: 7px; width: 40%;
    padding-right: 10px; white-space: nowrap; text-align: left;
    font-weight: 700; color: var(--mut); font-size: 11px;
  }
}

@media (max-width: 420px) {
  .hdr-logo-sub { display: none; }
  .sg { grid-template-columns: 1fr; }
}

/* ── Modal ───────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; padding: 20px;
}
.modal-box {
  background: #fff; border-radius: 14px; width: 100%; max-width: 520px;
  max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-lg { max-width: 860px; }
.modal-hdr {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px 12px; border-bottom: 1px solid var(--brd); flex-shrink: 0;
}
.modal-title { font-size: 15px; font-weight: 700; color: var(--pd); flex: 1; }
.modal-close {
  background: none; border: none; cursor: pointer; font-size: 16px;
  color: var(--fnt); padding: 2px 6px; border-radius: 5px;
}
.modal-close:hover { background: var(--bg); color: var(--txt); }
.modal-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  display: flex; gap: 8px; padding: 12px 20px 16px;
  border-top: 1px solid var(--brd); flex-wrap: wrap;
}

/* ── Toast ───────────────────────────────────── */
#toastRoot {
  position: fixed; bottom: 22px; right: 22px; z-index: 10000;
  display: flex; flex-direction: column; gap: 7px; pointer-events: none;
}
.toast {
  background: var(--pd); color: #fff;
  padding: 9px 15px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  box-shadow: 0 4px 14px rgba(0,0,0,.22);
  opacity: 0; transform: translateY(6px);
  transition: opacity .22s, transform .22s;
  pointer-events: none; max-width: 300px; line-height: 1.5;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-ok   { background: var(--ok); }
.toast-err  { background: var(--err); }
.toast-warn { background: var(--warn); }

/* ── 월 이동 UI ─────────────────────────────── */
.month-nav { display: flex; align-items: center; gap: 8px; }
.month-nav button {
  background: #fff; border: 1.5px solid var(--brd); border-radius: var(--radius-sm);
  width: 30px; height: 30px; font-size: 14px; color: var(--p); font-weight: 700;
}
.month-nav button:hover { background: var(--pl); }
.month-nav input[type="month"] { width: 140px; }

/* ── 요약 카드 3개 (수입/지출/수지) ─────────── */
.dash-sum { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.sc-val.neg { color: var(--err); }
.sc-val.pos { color: var(--ok); }

/* ── 목표 진행률 ────────────────────────────── */
.goal-list { display: flex; flex-direction: column; gap: 12px; }
.goal-row { cursor: pointer; padding: 4px 0; }
.goal-row-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; }
.goal-name { font-size: 13px; font-weight: 700; color: var(--txt); }
.goal-nums { font-size: 11.5px; color: var(--mut); }
.goal-pct  { font-size: 11.5px; font-weight: 700; color: var(--p); margin-left: 6px; }
.pbar-track { background: var(--bg); border-radius: 20px; height: 10px; overflow: hidden; }
.pbar-fill  { background: var(--p); height: 100%; border-radius: 20px; transition: width .3s; }
.pbar-fill.over { background: var(--acc); }
.goal-detail { margin-top: 10px; padding: 10px 12px; background: var(--bg); border-radius: var(--radius-sm); font-size: 12.5px; }
.goal-detail-row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed var(--brd); }
.goal-detail-row:last-child { border-bottom: none; }

/* ── 이달 처리 목록 ─────────────────────────── */
.pending-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 4px;
  border-bottom: 1px solid #EBF2F7; cursor: pointer;
}
.pending-row:last-child { border-bottom: none; }
.pending-row:hover { background: #F6FAFA; }
.pending-day { font-size: 11px; font-weight: 700; color: var(--mut); width: 34px; flex-shrink: 0; }
.pending-day.overdue { color: var(--err); }
.pending-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; }
.pending-name .sub { font-size: 11px; color: var(--fnt); font-weight: 400; margin-left: 4px; }
.pending-amt { font-size: 13px; font-weight: 700; color: var(--txt); white-space: nowrap; }
.pending-actions { display: flex; gap: 4px; flex-shrink: 0; }
.empty-box { padding: 20px; text-align: center; color: var(--fnt); font-size: 12.5px; }

/* ── 고정지출 매트릭스 ───────────────────────── */
.matrix-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
}
.matrix-grid.has-yh { grid-template-columns: repeat(5, 1fr); }
.matrix-col-hdr {
  font-size: 12px; font-weight: 700; color: var(--pd);
  margin-bottom: 8px; padding-bottom: 6px; border-bottom: 2px solid var(--pl2);
  display: flex; justify-content: space-between; align-items: baseline;
}
.matrix-col-hdr .cnt { font-size: 10.5px; color: var(--fnt); font-weight: 500; }
.matrix-col.yh-col .matrix-col-hdr { border-bottom-color: var(--brd); color: var(--mut); }
.matrix-row {
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
  padding: 7px 4px; border-bottom: 1px solid #EBF2F7; cursor: pointer; font-size: 12px;
}
.matrix-row:last-child { border-bottom: none; }
.matrix-row:hover { background: #F6FAFA; }
.matrix-row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matrix-row-amt { flex-shrink: 0; font-weight: 700; white-space: nowrap; }

@media (max-width: 768px) {
  .dash-sum { grid-template-columns: 1fr; }
  .matrix-grid, .matrix-grid.has-yh { grid-template-columns: 1fr; }
  .month-nav input[type="month"] { width: 120px; }
}

/* ── 통계 막대 리스트 ─────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.barlist { display: flex; flex-direction: column; gap: 8px; }
.barlist-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.barlist-label {
  width: 92px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; color: var(--mut); font-weight: 600;
}
.bar-track { flex: 1; background: var(--bg); border-radius: 20px; height: 9px; overflow: hidden; }
.bar-fill { background: var(--p); height: 100%; border-radius: 20px; }
.barlist-val { flex-shrink: 0; font-weight: 700; white-space: nowrap; min-width: 82px; text-align: right; }

/* ── 템플릿 목록 ───────────────────────────────── */
.tpl-row-terminated td { color: var(--fnt); }
.tpl-name-term { text-decoration: line-through; }

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ── 유동지출: 빠른입력 플로팅 버튼 ─────────────── */
.fab {
  position: fixed; right: 22px; bottom: 26px;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--p); color: #fff; font-size: 26px; font-weight: 300;
  border: none; box-shadow: var(--sh-lg); z-index: 250;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}
.fab:hover { background: var(--pd); }
@media (max-width: 768px) {
  .fab { bottom: 20px; right: 16px; width: 50px; height: 50px; }
}

.fab-menu {
  position: fixed; right: 22px; bottom: 90px; z-index: 250;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.fab-menu-item {
  background: #fff; border: 1.5px solid var(--brd); border-radius: 20px;
  padding: 9px 18px; font-size: 12.5px; font-weight: 700; color: var(--txt);
  box-shadow: var(--sh-lg); white-space: nowrap;
}
.fab-menu-item:hover { background: var(--pl); }
@media (max-width: 768px) {
  .fab-menu { bottom: 82px; right: 16px; }
}

/* ── 폼 공용 ───────────────────────────────── */
.req { color: var(--err); }
.amount-input-lg { font-size: 22px; font-weight: 700; text-align: right; padding: 10px 12px; }

/* ── 통계: 연도별 추세 차트 ─────────────────────── */
.trend-legend { display: flex; gap: 14px; font-size: 11px; color: var(--mut); margin-bottom: 10px; }
.trend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.trend-dot.income  { background: var(--ok); }
.trend-dot.expense { background: var(--err); }
.trend-chart {
  display: flex; align-items: flex-end; gap: 10px; height: 200px;
  min-width: 600px; padding-bottom: 4px;
}
.trend-col { flex: 0 0 44px; display: flex; flex-direction: column; align-items: center; height: 100%; }
.trend-bars { flex: 1; display: flex; align-items: flex-end; gap: 3px; width: 100%; }
.trend-bar { flex: 1; border-radius: 3px 3px 0 0; min-height: 2px; transition: height .3s; }
.trend-bar.income  { background: var(--ok); }
.trend-bar.expense { background: var(--err); }
.trend-balance { font-size: 9.5px; font-weight: 700; margin-top: 4px; color: var(--mut); white-space: nowrap; }
.trend-balance.neg { color: var(--err); }
.trend-balance.pos { color: var(--ok); }
.trend-month-label { font-size: 10.5px; color: var(--mut); margin-top: 2px; }

.bar-fill.ref { background: var(--fnt); }

/* ── 부채 화면 요약 (2열) ─────────────────────── */
.dash-sum-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 768px) {
  .dash-sum-2 { grid-template-columns: 1fr; }
}

/* ── AI 분석 결과 ───────────────────────────── */
.ai-content { font-size: 13px; line-height: 1.8; color: var(--txt); white-space: pre-wrap; }
.ai-content .md-h1 { display: block; color: var(--pd); font-size: 15px; margin: 10px 0 4px; }
.ai-content .md-h2 { display: block; color: var(--pd); font-size: 14px; margin: 10px 0 4px; }
.ai-content .md-h3 { display: block; color: var(--p);  font-size: 13px; margin: 8px 0 3px; }

/* ── 설정: 목록 편집 (칩) ───────────────────────── */
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; min-height: 24px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--pl); color: var(--p); font-size: 12px; font-weight: 600;
  padding: 4px 6px 4px 10px; border-radius: 20px;
}
.chip-x {
  background: none; border: none; color: var(--p); cursor: pointer;
  font-size: 11px; padding: 2px 5px; border-radius: 50%; line-height: 1;
}
.chip-x:hover { background: rgba(0,0,0,.08); }

/* ── 대시보드: 확대된 월 선택 UI ─────────────────── */
.month-nav-lg { display: flex; align-items: center; gap: 10px; }
.month-nav-lg button {
  background: #fff; border: 1.5px solid var(--brd); border-radius: var(--radius-sm);
  width: 42px; height: 42px; font-size: 20px; color: var(--p); font-weight: 700;
}
.month-nav-lg button:hover { background: var(--pl); }
.month-nav-lg input[type="month"] { width: 190px; font-size: 19px; font-weight: 700; padding: 8px 10px; color: var(--pd); }
@media (max-width: 768px) {
  .month-nav-lg input[type="month"] { width: 150px; font-size: 16px; }
  .month-nav-lg button { width: 38px; height: 38px; font-size: 18px; }
}

/* ── 대시보드: 통합 요약+목표 7박스 행 ───────────── */
.summary-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 28px; }
.summary-box {
  flex: 0 0 155px; background: var(--bg-w); border: 1px solid var(--brd); border-radius: var(--radius);
  padding: 8px 12px; box-shadow: var(--sh); cursor: pointer; transition: box-shadow .15s, transform .15s;
}
.summary-box:hover { box-shadow: var(--sh-lg); transform: translateY(-1px); }
.summary-box .sc-lbl { font-size: 9px; color: var(--mut); letter-spacing: .5px; text-transform: uppercase; margin-bottom: 3px; }
.summary-box .sc-val { font-size: 16px; font-weight: 700; color: var(--p); letter-spacing: -0.5px; line-height: 1.1; }
.summary-box .sc-val.neg { color: var(--err); }
.summary-box .sc-val.pos { color: var(--ok); }
.summary-box .sc-sub { font-size: 9.5px; color: var(--fnt); margin-top: 2px; }
.summary-box .pbar-track { margin-top: 5px; height: 5px; }
@media (max-width: 768px) {
  .summary-box { flex: 0 0 138px; padding: 8px 10px; }
}

/* ── 대시보드: 미처리 고정지출 카드 그리드 ───────── */
.pending-group { margin-bottom: 16px; }
.pending-group:last-child { margin-bottom: 0; }
.pending-group-title {
  font-size: 12px; font-weight: 700; color: var(--pd);
  margin-bottom: 8px; padding-bottom: 4px; border-bottom: 1px solid var(--brd);
}
.pending-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.pending-card {
  background: #fff; border: 1px solid var(--brd); border-radius: var(--radius-sm);
  padding: 10px 12px; cursor: pointer; transition: box-shadow .15s;
  display: flex; flex-direction: column; gap: 6px;
}
.pending-card:hover { box-shadow: var(--sh); }
.pending-card-day { font-size: 11px; font-weight: 700; color: var(--mut); }
.pending-card-day.overdue { color: var(--err); }
.pending-card-name { font-size: 12.5px; font-weight: 600; line-height: 1.3; }
.pending-card-name .sub { font-size: 10px; color: var(--fnt); font-weight: 400; margin-left: 3px; }
.pending-card-amt { font-size: 13px; font-weight: 700; }
.pending-card-actions { display: flex; gap: 4px; margin-top: 2px; }
.pending-card-actions .btn { flex: 1; padding: 4px 6px; font-size: 10.5px; }
/* 미해결 카드(dashboardOverdue.js): 버튼 제거로 항목이 단순해져 카드 자체 크기를 축소 */
.pending-card-compact { padding: 7px 10px; gap: 3px; }
.pending-card-compact .pending-card-name { font-size: 12px; }
.pending-card-compact .pending-card-amt { font-size: 12.5px; }
@media (max-width: 1024px) { .pending-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px)  { .pending-grid { grid-template-columns: 1fr; } }

/* ── 대시보드: 월간 달력 ──────────────────────── */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-weekday { text-align: center; font-size: 11px; font-weight: 700; color: var(--mut); padding: 4px 0 8px; }
.cal-day {
  border-radius: 6px; padding: 5px; cursor: pointer; background: #fff;
  min-height: 76px; display: flex; flex-direction: column; gap: 2px;
  border: 1px solid var(--brd); transition: box-shadow .15s;
}
.cal-day:hover { box-shadow: var(--sh); }
.cal-day.empty { background: transparent; border: none; cursor: default; box-shadow: none; }
.cal-day.today { background: var(--pl); }
.cal-day-num { font-size: 11px; font-weight: 700; color: var(--txt); margin-bottom: 2px; }
.cal-day-line {
  font-size: 9px; line-height: 1.4; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; color: var(--mut);
}
.cal-day-line.income  { color: var(--ok); }
.cal-day-line.expense { color: var(--txt); }
.cal-day-line.fixed   { color: var(--txt); }
.cal-day-line.fixed.unprocessed { color: var(--err); font-weight: 700; }

@media (max-width: 768px) {
  .cal-day { min-height: 60px; min-width: 44px; padding: 4px 3px; }
  .cal-day-line { font-size: 8px; }
  .cal-grid { gap: 3px; }
}

/* ── 대시보드: 상단 우측(AI 분석 버튼 + 월 선택) ─── */
.dash-top-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* ── 탭 (고정지출 템플릿: 활성/휴지통) ───────────── */
.tabs { display: flex; gap: 6px; margin-bottom: 12px; border-bottom: 1px solid var(--brd); }
.tab-btn {
  background: none; border: none; padding: 8px 4px; margin-bottom: -1px;
  font-size: 13px; font-weight: 600; color: var(--mut);
  border-bottom: 2px solid transparent; display: flex; align-items: center; gap: 5px;
}
.tab-btn:hover { color: var(--p); }
.tab-btn.active { color: var(--p); border-bottom-color: var(--p); }

/* ── 날짜/박스 상세 모달 공용 ──────────────────── */
.day-modal-total {
  display: flex; justify-content: space-between; padding: 8px 10px;
  background: var(--bg); border-radius: var(--radius-sm); font-size: 13px; font-weight: 700; margin-bottom: 12px;
}
.day-section-title { font-size: 12px; font-weight: 700; color: var(--pd); margin: 14px 0 6px; }
.day-section-title:first-of-type { margin-top: 0; }
.day-item-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 4px; border-bottom: 1px solid #EBF2F7; cursor: pointer; font-size: 12.5px;
}
.day-item-row:hover { background: #F6FAFA; }
.day-item-row:last-child { border-bottom: none; }

/* ── 설정: 주체 관리 (유형 토글 리스트) ─────────── */
.subject-list { display: flex; flex-direction: column; gap: 6px; }
.subject-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--brd); }
.subject-row:last-child { border-bottom: none; }
.subject-name { flex: 1; font-size: 13px; font-weight: 600; color: var(--txt); }
.type-toggle { display: flex; border: 1px solid var(--brd); border-radius: 20px; overflow: hidden; flex-shrink: 0; }
.type-btn { background: #fff; border: none; padding: 4px 10px; font-size: 11px; font-weight: 600; color: var(--mut); }
.type-btn:first-child { border-right: 1px solid var(--brd); }
.type-btn.active { background: var(--p); color: #fff; }

/* ── 고정지출 워크스페이스 (매트릭스) ────────────── */
.dash-sum-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 768px) { .dash-sum-3 { grid-template-columns: 1fr; } }

.fx-legend { display: flex; gap: 14px; font-size: 11px; color: var(--mut); margin: 10px 0; flex-wrap: wrap; }
.fx-legend-item { display: flex; align-items: center; gap: 5px; }
.fx-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.fx-dot.upcoming { background: var(--fnt); }
.fx-dot.done     { background: var(--ok); }
.fx-dot.overdue  { background: var(--err); }
.fx-dot.skipped  { background: #ddd; }

.fx-matrix-mobile { display: none; }
@media (max-width: 768px) {
  .fx-matrix-desktop { display: none; }
  .fx-matrix-mobile { display: block; }
}

.fx-cell-item { padding: 3px 0; }
.fx-cell-item + .fx-cell-item { border-top: 1px dashed #EBF2F7; margin-top: 3px; padding-top: 6px; }
.fx-cell-main { display: flex; align-items: center; gap: 5px; font-size: 11.5px; cursor: pointer; }
.fx-cell-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-cell-amt { font-weight: 700; white-space: nowrap; }
.fx-cell-actions { display: flex; gap: 3px; margin: 3px 0 2px 14px; }

/* ── 대시보드: 거래 피드 ─────────────────────── */
.feed-filters { display: flex; gap: 16px; margin-bottom: 12px; }
.feed-filters label { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--txt); text-transform: none; cursor: pointer; }
.feed-filters input[type="checkbox"] { width: auto; }

.feed-group + .feed-group { margin-top: 14px; }
.feed-group-hdr {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 8px; background: var(--bg); border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 700; color: var(--pd); margin-bottom: 4px;
}
.feed-group-sums { display: flex; gap: 8px; font-size: 11.5px; font-weight: 700; }
.feed-sum-income  { color: var(--inf); }
.feed-sum-expense { color: var(--err); }

.feed-items { display: flex; flex-direction: column; }
.feed-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 8px 8px; border-bottom: 1px solid #EBF2F7; cursor: pointer;
}
.feed-item:hover { background: #F6FAFA; }
.feed-item:last-child { border-bottom: none; }
.feed-item-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.feed-item-name { font-size: 13.5px; font-weight: 700; color: var(--txt); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-item-sub { font-size: 10.5px; font-weight: 400; color: var(--fnt); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-item-tags { display: flex; align-items: center; gap: 6px; font-size: 10.5px; margin-top: 1px; }
.feed-item-amt { font-size: 13px; font-weight: 700; white-space: nowrap; }
.feed-amt-income  { color: var(--inf); }
.feed-amt-expense { color: var(--err); }

/* ── 유동지출 빠른 입력: 복수 항목 행 / 영수증 이미지 첨부 ─────── */
.qa-item-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.qa-item-row .qa-item-name { flex: 1.4; }
.qa-item-row .qa-item-amount { flex: 1; }
.qa-item-row .qa-item-del { flex-shrink: 0; padding: 6px 10px; font-size: 11px; }

.qa-image-area { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.qa-image-preview {
  display: block; margin-top: 8px; max-width: 140px; max-height: 140px;
  border-radius: var(--radius-sm); border: 1px solid var(--brd); object-fit: cover;
}

/* ── 고정지출 수정 모달: 상태 세그먼트 컨트롤 ─────── */
.status-segment { display: flex; gap: 6px; flex-wrap: wrap; }
.status-seg-btn {
  flex: 1 1 90px; padding: 12px 8px; border: 1.5px solid var(--brd); border-radius: var(--radius-sm);
  background: #fff; font-size: 13px; font-weight: 700; color: var(--mut); text-align: center;
}
.status-seg-btn:hover { background: var(--bg); }
.status-seg-btn.active { background: var(--p); border-color: var(--p); color: #fff; }
@media (max-width: 768px) {
  .status-seg-btn { flex: 1 1 40%; font-size: 12px; padding: 10px 6px; }
}

/* ── 유동지출 등록/수정 공용 폼: 기존 첨부 이미지 ─────── */
.ef-existing-file { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── 거래 상세 뷰어 모달 ─────── */
.tx-detail-total { padding: 10px 12px; background: var(--bg); border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 700; margin-bottom: 12px; }
.tx-detail-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid #EBF2F7; font-size: 12.5px; }
.tx-detail-row:last-child { border-bottom: none; }
.tx-detail-label { color: var(--mut); }
.tx-detail-items { margin: 8px 0; }
.tx-detail-item-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 12.5px; }
.tx-detail-img { max-width: 220px; max-height: 220px; border-radius: var(--radius-sm); border: 1px solid var(--brd); margin-top: 8px; object-fit: cover; }

/* ── 미해결 목록: 참조 항목 접힌 섹션 ─────── */
.overdue-ref-toggle {
  display: flex; align-items: center; gap: 6px; background: none; border: none;
  font-size: 12.5px; font-weight: 700; color: var(--mut); padding: 8px 0; width: 100%; text-align: left;
}
.overdue-ref-toggle:hover { color: var(--txt); }
.overdue-ref-section { display: none; margin-top: 6px; }
.overdue-ref-section.open { display: block; }
