/* ============================================
   모으미 · 라이프 가계부 — 파스텔 테마
   ============================================ */
:root{
  --bg: #F6F5FB;
  --surface: #FFFFFF;
  --surface-2: #FBFAFF;
  --primary: #B8A9F3;
  --primary-dark: #9A87E8;
  --pink: #FFD6E8;
  --pink-dark: #FFAFD3;
  --mint: #BDF0DA;
  --mint-dark: #7FDDB5;
  --peach: #FFDDB3;
  --peach-dark: #FFC583;
  --sky: #C3E4FF;
  --sky-dark: #8FCBFF;
  --ink: #4A4458;
  --ink-soft: #6E6680;
  --muted: #9C96AC;
  --line: #ECE9F7;
  --danger: #FF9B9B;
  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --shadow: 0 8px 24px rgba(150, 130, 210, 0.14);
  --shadow-sm: 0 4px 12px rgba(150, 130, 210, 0.10);
  --font-display: 'Jua', 'Gowun Dodum', sans-serif;
  --font-body: 'Pretendard', -apple-system, 'Noto Sans KR', sans-serif;
}

[data-theme="dark"]{
  --bg: #221F2E;
  --surface: #2C2839;
  --surface-2: #322D42;
  --ink: #F1EEF9;
  --ink-soft: #CFC9DE;
  --muted: #948DA8;
  --line: #3B3550;
  --shadow: 0 8px 24px rgba(0,0,0,0.35);
  --shadow-sm: 0 4px 12px rgba(0,0,0,0.28);
}

*{box-sizing:border-box;}
html,body{margin:0;padding:0;height:100%;}
body{
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
.hidden{display:none !important;}
button{font-family:inherit; cursor:pointer; border:none; background:none;}
input, select, textarea{font-family:inherit;}

/* ---------- 로그인 화면 ---------- */
.auth-screen, .lock-screen{
  min-height:100dvh; display:flex; align-items:center; justify-content:center;
  background: linear-gradient(160deg, #EFE9FF 0%, #F6F5FB 45%, #FFE9F3 100%);
  padding:24px;
}
.auth-card, .lock-card{
  width:100%; max-width:360px; background:var(--surface); border-radius:var(--radius-lg);
  padding:36px 28px; box-shadow:var(--shadow); text-align:center;
}
.auth-logo{font-size:48px; margin-bottom:6px;}
.auth-title{font-family:var(--font-display); font-size:32px; margin:0 0 4px; color:var(--ink);}
.auth-sub{color:var(--muted); font-size:14px; margin:0 0 22px;}
#authForm{display:flex; flex-direction:column; gap:10px;}
.auth-card input, .lock-card input{
  padding:14px 16px; border-radius:var(--radius-md); border:1.5px solid var(--line);
  background:var(--surface-2); font-size:15px; color:var(--ink); outline:none;
  transition:border-color .15s;
}
.auth-card input:focus, .lock-card input:focus{border-color:var(--primary);}
.lock-card input{text-align:center; letter-spacing:8px; font-size:22px;}
.btn-primary{
  margin-top:6px; padding:14px; border-radius:var(--radius-md); background:var(--primary);
  color:#fff; font-weight:700; font-size:15px; box-shadow:var(--shadow-sm);
  transition:transform .1s, background .15s;
}
.btn-primary:active{transform:scale(0.97);}
.btn-primary:hover{background:var(--primary-dark);}
.btn-ghost{
  margin-top:10px; color:var(--muted); font-size:13px; text-decoration:underline;
  display:block; width:100%;
}
.auth-error{color:#E36767; font-size:13px; min-height:18px; margin-top:10px;}

/* ---------- 앱 레이아웃 ---------- */
.app{min-height:100dvh; display:flex; flex-direction:column;}
.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding:16px 20px; background:var(--bg); position:sticky; top:0; z-index:20;
}
.brand{font-family:var(--font-display); font-size:20px; color:var(--ink); display:flex; align-items:center; gap:6px;}
.topbar-right{display:flex; gap:8px;}
.icon-btn{
  width:40px; height:40px; border-radius:50%; background:var(--surface);
  display:flex; align-items:center; justify-content:center; font-size:18px;
  box-shadow:var(--shadow-sm); position:relative;
}
.dot{position:absolute; top:8px; right:8px; width:8px; height:8px; border-radius:50%; background:var(--danger);}

.view-container{flex:1; padding:0 16px 100px; max-width:560px; margin:0 auto; width:100%;}

.tabbar{
  position:fixed; bottom:0; left:0; right:0; background:var(--surface);
  display:flex; justify-content:space-around; padding:8px 4px calc(8px + env(safe-area-inset-bottom));
  box-shadow:0 -4px 16px rgba(150,130,210,0.12); z-index:30;
}
.tab-btn{
  display:flex; flex-direction:column; align-items:center; gap:2px; font-size:11px;
  color:var(--muted); padding:6px 10px; border-radius:14px; transition:all .15s;
}
.tab-btn span{font-size:20px;}
.tab-btn.active{color:var(--primary-dark); font-weight:700; background:var(--line);}

.fab{
  position:fixed; right:20px; bottom:88px; width:56px; height:56px; border-radius:50%;
  background:linear-gradient(145deg, var(--primary), var(--primary-dark)); color:#fff; font-size:28px;
  box-shadow:0 10px 24px rgba(154,135,232,0.45); z-index:25; display:flex; align-items:center; justify-content:center;
  transition:transform .12s;
}
.fab:active{transform:scale(0.92) rotate(90deg);}

/* ---------- 카드/공통 ---------- */
.section-title{font-family:var(--font-display); font-size:18px; margin:22px 0 12px; color:var(--ink); display:flex; align-items:center; justify-content:space-between;}
.section-title .more-link{font-size:12px; color:var(--muted); font-family:var(--font-body); font-weight:500;}
.card{
  background:var(--surface); border-radius:var(--radius-md); padding:18px; box-shadow:var(--shadow-sm);
  margin-bottom:14px;
}
.card-row{display:flex; align-items:center; justify-content:space-between; gap:10px;}

/* ---------- 대시보드 요약 ---------- */
.summary-hero{
  background: linear-gradient(150deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius:var(--radius-lg); padding:24px; color:#fff; box-shadow:var(--shadow); margin-top:14px;
}
.summary-hero .label{font-size:13px; opacity:0.85;}
.summary-hero .amount{font-family:var(--font-display); font-size:36px; margin:4px 0 14px;}
.progress-track{height:10px; border-radius:10px; background:rgba(255,255,255,0.3); overflow:hidden;}
.progress-fill{height:100%; border-radius:10px; background:#fff; transition:width .4s;}
.summary-hero .sub-row{display:flex; justify-content:space-between; font-size:12px; margin-top:8px; opacity:0.9;}

.jar-grid{display:grid; grid-template-columns:repeat(4,1fr); gap:10px; margin-top:16px;}
.jar{display:flex; flex-direction:column; align-items:center; gap:6px;}
.jar-glass{
  width:52px; height:64px; border-radius:10px 10px 18px 18px; border:2.5px solid var(--line);
  position:relative; overflow:hidden; background:var(--surface-2);
}
.jar-liquid{position:absolute; left:0; right:0; bottom:0; transition:height .5s ease;}
.jar-label{font-size:11px; color:var(--ink-soft); font-weight:600;}
.jar-pct{font-size:10px; color:var(--muted);}

.quick-add-grid{display:grid; grid-template-columns:repeat(3,1fr); gap:10px; margin-top:14px;}
.quick-add-btn{
  background:var(--surface); border-radius:var(--radius-sm); padding:14px 6px; text-align:center;
  box-shadow:var(--shadow-sm); font-size:12px; color:var(--ink-soft); font-weight:600;
}
.quick-add-btn span{display:block; font-size:22px; margin-bottom:4px;}

.list-item{
  display:flex; align-items:center; gap:12px; padding:12px 0; border-bottom:1px solid var(--line);
}
.list-item:last-child{border-bottom:none;}
.list-icon{
  width:42px; height:42px; border-radius:14px; display:flex; align-items:center; justify-content:center;
  font-size:20px; flex-shrink:0;
}
.list-main{flex:1; min-width:0;}
.list-title{font-weight:600; font-size:14px; color:var(--ink);}
.list-sub{font-size:12px; color:var(--muted); margin-top:2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.list-amount{font-weight:700; font-size:14px; white-space:nowrap;}
.amount-out{color:#E88A9A;}
.amount-in{color:#5FBE94;}

.empty-state{text-align:center; color:var(--muted); padding:40px 10px; font-size:13px;}
.empty-state .emoji{font-size:36px; display:block; margin-bottom:8px;}

/* ---------- 필터/탭칩 ---------- */
.chip-row{display:flex; gap:8px; overflow-x:auto; padding:4px 0 10px; scrollbar-width:none;}
.chip-row::-webkit-scrollbar{display:none;}
.chip{
  padding:8px 16px; border-radius:20px; background:var(--surface); font-size:13px; color:var(--ink-soft);
  white-space:nowrap; box-shadow:var(--shadow-sm); font-weight:600;
}
.chip.active{background:var(--primary); color:#fff;}

.search-bar{
  display:flex; align-items:center; gap:8px; background:var(--surface); border-radius:var(--radius-md);
  padding:10px 14px; box-shadow:var(--shadow-sm); margin-top:10px;
}
.search-bar input{flex:1; border:none; background:none; outline:none; font-size:14px; color:var(--ink);}

/* ---------- 고정비 ---------- */
.badge{font-size:10px; padding:3px 8px; border-radius:8px; font-weight:700;}
.badge-soon{background:var(--peach); color:#8A5A22;}
.badge-done{background:var(--mint); color:#227A54;}

/* ---------- 할부 ---------- */
.install-card{background:var(--surface); border-radius:var(--radius-md); padding:16px; box-shadow:var(--shadow-sm); margin-bottom:12px;}
.install-progress-track{height:8px; border-radius:8px; background:var(--line); overflow:hidden; margin:10px 0 6px;}
.install-progress-fill{height:100%; background:linear-gradient(90deg, var(--sky-dark), var(--primary)); border-radius:8px;}

/* ---------- 경조사 ---------- */
.person-avatar{
  width:42px; height:42px; border-radius:50%; background:var(--pink); display:flex; align-items:center;
  justify-content:center; font-size:16px; font-weight:700; color:#B8578C; flex-shrink:0;
}

/* ---------- 달력 ---------- */
.cal-header{display:flex; align-items:center; justify-content:space-between; margin:14px 0;}
.cal-header button{font-size:18px; color:var(--muted); padding:6px 10px;}
.cal-header h3{font-family:var(--font-display); font-size:18px; margin:0;}
.cal-grid{display:grid; grid-template-columns:repeat(7,1fr); gap:4px; text-align:center;}
.cal-dow{font-size:11px; color:var(--muted); padding:6px 0; font-weight:700;}
.cal-day{
  aspect-ratio:1; border-radius:12px; display:flex; flex-direction:column; align-items:center; justify-content:flex-start;
  padding-top:6px; font-size:12px; color:var(--ink-soft); background:var(--surface-2); position:relative; gap:2px;
}
.cal-day.today{border:2px solid var(--primary); font-weight:700; color:var(--primary-dark);}
.cal-day.empty{background:none;}
.cal-dots{display:flex; gap:2px; flex-wrap:wrap; justify-content:center; margin-top:2px;}
.cal-dot{width:5px; height:5px; border-radius:50%;}

/* ---------- 통계 ---------- */
.stat-chart-wrap{background:var(--surface); border-radius:var(--radius-md); padding:18px; box-shadow:var(--shadow-sm); margin-bottom:14px;}
.legend-row{display:flex; align-items:center; gap:8px; font-size:12px; color:var(--ink-soft); margin-top:6px;}
.legend-dot{width:10px; height:10px; border-radius:50%;}
.ai-report-box{
  background:linear-gradient(135deg, var(--sky), var(--pink)); border-radius:var(--radius-md); padding:18px;
  font-size:13px; line-height:1.7; color:#3D3455; box-shadow:var(--shadow-sm);
}

/* ---------- 자산 ---------- */
.asset-net{text-align:center; padding:20px 0;}
.asset-net .amount{font-family:var(--font-display); font-size:30px;}
.asset-type-icon{width:42px; height:42px; border-radius:14px; display:flex; align-items:center; justify-content:center; font-size:20px;}

/* ---------- 설정 ---------- */
.settings-group{background:var(--surface); border-radius:var(--radius-md); box-shadow:var(--shadow-sm); margin-bottom:14px; overflow:hidden;}
.settings-row{display:flex; align-items:center; justify-content:space-between; padding:16px 18px; border-bottom:1px solid var(--line); font-size:14px;}
.settings-row:last-child{border-bottom:none;}
.settings-row .label{display:flex; align-items:center; gap:10px;}
.switch{width:44px; height:26px; border-radius:20px; background:var(--line); position:relative; transition:background .2s;}
.switch.on{background:var(--primary);}
.switch::after{content:''; position:absolute; top:3px; left:3px; width:20px; height:20px; border-radius:50%; background:#fff; transition:left .2s; box-shadow:0 2px 4px rgba(0,0,0,0.2);}
.switch.on::after{left:21px;}

/* ---------- 모달 ---------- */
.modal-backdrop{
  position:fixed; inset:0; background:rgba(60,50,90,0.35); z-index:100; display:flex; align-items:flex-end;
  backdrop-filter:blur(2px);
}
.modal{
  background:var(--surface); width:100%; max-height:92dvh; overflow-y:auto; border-radius:26px 26px 0 0;
  padding:22px 20px calc(24px + env(safe-area-inset-bottom)); animation:slideUp .25s ease;
}
@keyframes slideUp{from{transform:translateY(30px); opacity:0;} to{transform:translateY(0); opacity:1;}}
.modal-handle{width:40px; height:5px; background:var(--line); border-radius:10px; margin:0 auto 16px;}
.modal h2{font-family:var(--font-display); font-size:20px; margin:0 0 16px; color:var(--ink);}
.form-group{margin-bottom:14px;}
.form-group label{display:block; font-size:12px; color:var(--muted); margin-bottom:6px; font-weight:600;}
.form-group input, .form-group select, .form-group textarea{
  width:100%; padding:13px 14px; border-radius:var(--radius-sm); border:1.5px solid var(--line);
  background:var(--surface-2); font-size:14px; color:var(--ink); outline:none;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus{border-color:var(--primary);}
.form-group textarea{resize:vertical; min-height:60px;}
.form-row{display:flex; gap:10px;}
.form-row .form-group{flex:1;}
.seg-control{display:flex; background:var(--surface-2); border-radius:var(--radius-sm); padding:4px; gap:4px;}
.seg-btn{flex:1; text-align:center; padding:10px 4px; border-radius:10px; font-size:13px; color:var(--ink-soft); font-weight:600;}
.seg-btn.active{background:var(--primary); color:#fff;}
.modal-actions{display:flex; gap:10px; margin-top:18px;}
.btn-secondary{flex:1; padding:14px; border-radius:var(--radius-md); background:var(--surface-2); color:var(--ink-soft); font-weight:700;}
.btn-danger{color:#E36767;}
.file-preview{display:flex; gap:8px; flex-wrap:wrap; margin-top:8px;}
.file-preview img{width:60px; height:60px; object-fit:cover; border-radius:10px;}

.toast{
  position:fixed; bottom:100px; left:50%; transform:translateX(-50%); background:var(--ink); color:#fff;
  padding:12px 22px; border-radius:20px; font-size:13px; z-index:200; box-shadow:var(--shadow);
}

@media(min-width:600px){
  .modal-backdrop{align-items:center;}
  .modal{max-width:420px; border-radius:26px;}
}
