/* ==========================================================================
   부부 스마트 가계부 (Smart Family Expense Tracker) Design System
   ========================================================================== */

:root {
  /* 색상 토큰 (라이트 모드 기본) */
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-subtle: #f1f5f9;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;

  /* 포인트 브랜드 컬러 */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;

  --rose: #e11d48;
  --rose-light: #ffe4e6;
  --emerald: #059669;
  --emerald-light: #d1fae5;
  --amber: #d97706;
  --amber-light: #fef3c7;
  --indigo: #4f46e5;
  --indigo-light: #e0e7ff;
  --slate: #475569;
  --slate-light: #f1f5f9;

  --kakao-yellow: #fee500;
  --kakao-text: #191919;
  --kakao-hover: #fada0a;

  /* 그림자 & 라운딩 */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.06);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --font-sans: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-num: 'Plus Jakarta Sans', 'Pretendard', sans-serif;
}

/* 다크 테마 */
body.dark-theme {
  --bg-app: #0b0f19;
  --bg-surface: #131b2e;
  --bg-surface-elevated: #1a243b;
  --bg-subtle: #1e293b;
  --border-color: #2a374f;
  --border-focus: #60a5fa;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;

  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: #1e293b;

  --rose: #fb7185;
  --rose-light: #381b24;
  --emerald: #34d399;
  --emerald-light: #064e3b;
  --amber: #fbbf24;
  --amber-light: #451a03;
  --indigo: #818cf8;
  --indigo-light: #1e1e38;
  --slate: #94a3b8;
  --slate-light: #1e293b;

  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

/* 기본 리셋 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  transition: background-color 0.25s ease, color 0.25s ease;
}

body.modal-open {
  overflow: hidden;
}

/* ==========================================================================
   헤더 네비게이션
   ========================================================================== */
.app-header {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(10px);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 28px;
  background: var(--bg-subtle);
  padding: 6px 10px;
  border-radius: var(--radius-md);
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.brand-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* 월 선택 컨트롤러 */
.month-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-subtle);
  padding: 4px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

.current-month {
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 1rem;
  min-width: 110px;
  text-align: center;
  color: var(--text-main);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ==========================================================================
   공통 버튼 & 뱃지
   ========================================================================== */
button {
  cursor: pointer;
  border: none;
  background: none;
  font-size: 0.9rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
  border-radius: var(--radius-md);
  padding: 8px 14px;
}

button:active {
  transform: scale(0.97);
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-full);
  color: var(--text-muted);
}
.btn-icon:hover {
  background-color: var(--bg-surface);
  color: var(--text-main);
}

.btn-icon-circle {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-full);
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  font-size: 1.1rem;
}
.btn-icon-circle:hover {
  background-color: var(--border-color);
}

.btn-pill {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  background-color: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}
.btn-pill:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-secondary {
  background-color: var(--bg-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover {
  background-color: var(--border-color);
}

.btn-highlight {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}
.btn-highlight:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-kakao {
  background-color: var(--kakao-yellow);
  color: var(--kakao-text);
  font-weight: 700;
}
.btn-kakao:hover {
  background-color: var(--kakao-hover);
  box-shadow: 0 4px 10px rgba(254, 229, 0, 0.3);
}

.btn-outline {
  border: 1px solid var(--border-color);
  color: var(--text-main);
  background-color: var(--bg-surface);
}
.btn-outline:hover {
  background-color: var(--bg-subtle);
  border-color: var(--text-muted);
}

.btn-danger-outline {
  border: 1px solid var(--rose);
  color: var(--rose);
  background-color: transparent;
}
.btn-danger-outline:hover {
  background-color: var(--rose-light);
}

.btn-link {
  padding: 0;
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
}
.btn-link:hover {
  text-decoration: underline;
}

.file-input-label {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
}

/* 뱃지 */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.badge-rose { background: var(--rose-light); color: var(--rose); }
.badge-emerald { background: var(--emerald-light); color: var(--emerald); }
.badge-amber { background: var(--amber-light); color: var(--amber); }
.badge-indigo { background: var(--indigo-light); color: var(--indigo); }
.badge-slate { background: var(--slate-light); color: var(--slate); }

.text-rose { color: var(--rose) !important; }
.text-emerald { color: var(--emerald) !important; }
.text-slate { color: var(--slate) !important; }

/* ==========================================================================
   메인 레이아웃 & 대시보드 그리드
   ========================================================================== */
.main-layout {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* 1. 요약 카드 그리드 */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.summary-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.summary-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-icon {
  font-size: 1.4rem;
}

.metric-value {
  font-family: var(--font-num);
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
  margin-bottom: 4px;
}

.metric-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* 누적 스택 프로그레스 바 */
.progress-bar-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-bar-stacked {
  height: 8px;
  background-color: var(--bg-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
  display: flex;
}

.bar-segment {
  height: 100%;
  transition: width 0.4s ease;
}
.bar-fixed { background-color: var(--slate); }
.bar-var { background-color: var(--rose); }

.bar-legend {
  display: flex;
  gap: 12px;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.dot-fixed { background-color: var(--slate); }
.dot-var { background-color: var(--rose); }

.card-footer-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px dashed var(--border-color);
  padding-top: 10px;
}

/* 예산 게이지 */
.budget-meter {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meter-text {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.meter-track {
  height: 8px;
  background-color: var(--bg-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  background-color: var(--emerald);
  transition: width 0.4s ease, background-color 0.3s;
}

.meter-fill.warning { background-color: var(--amber); }
.meter-fill.danger { background-color: var(--rose); }

/* 가계 평화 지수 카드 */
.peace-score-box {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.peace-emoji {
  font-size: 2rem;
  background: var(--amber-light);
  padding: 6px;
  border-radius: var(--radius-md);
  line-height: 1;
}

.peace-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 2px;
}

.peace-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ==========================================================================
   2. 차트 & 분석 영역
   ========================================================================== */
.analytics-section {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 18px;
}

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

.chart-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.section-title-row h3 {
  font-size: 1rem;
  font-weight: 700;
}

.chart-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.chart-wrapper {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.donut-chart-box {
  position: relative;
  width: 200px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.donut-center-label {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.center-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.center-val {
  font-family: var(--font-num);
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-main);
}

.category-legend-list {
  flex: 1;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
}

.legend-left {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.legend-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-amount {
  font-family: var(--font-num);
  font-weight: 700;
  color: var(--text-main);
}

.daily-chart-wrapper {
  width: 100%;
  overflow-x: auto;
  padding-top: 10px;
}

.daily-chart-wrapper canvas {
  width: 100%;
  max-height: 200px;
}

/* ==========================================================================
   3. 메인 탭 영역
   ========================================================================== */
.content-tabs-section {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.tabs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 14px;
  gap: 16px;
  flex-wrap: wrap;
}

.tab-buttons {
  display: flex;
  gap: 8px;
}

.tab-btn {
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  color: var(--text-muted);
  background-color: var(--bg-subtle);
  border: 1px solid transparent;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  background-color: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
  font-weight: 700;
}

.tab-panel {
  display: none;
  padding-top: 18px;
}

.tab-panel.active {
  display: block;
}

/* 필터 바 */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 220px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.search-box input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-subtle);
  color: var(--text-main);
  font-size: 0.88rem;
  outline: none;
}

.search-box input:focus {
  border-color: var(--border-focus);
  background-color: var(--bg-surface);
}

.filter-selects {
  display: flex;
  gap: 8px;
}

.custom-select {
  padding: 9px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-subtle);
  color: var(--text-main);
  font-size: 0.88rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

/* 트랜잭션 날짜별 그룹 리스트 */
.transaction-list-container {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.date-group-card {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.date-group-header {
  padding: 8px 14px;
  background-color: rgba(0, 0, 0, 0.02);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
}

.date-daily-sum {
  font-family: var(--font-num);
  color: var(--rose);
}

.tx-items-list {
  display: flex;
  flex-direction: column;
}

.tx-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  transition: background-color 0.15s ease;
}

.tx-item-row:last-child {
  border-bottom: none;
}

.tx-item-row:hover {
  background-color: var(--bg-subtle);
}

.tx-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tx-category-icon {
  font-size: 1.4rem;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
}

.tx-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tx-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.tx-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.tx-memo-tag {
  background-color: var(--primary-light);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.72rem;
}

.tx-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.tx-amount {
  font-family: var(--font-num);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--rose);
}

.tx-actions {
  display: flex;
  gap: 4px;
}

.btn-action-icon {
  padding: 4px;
  color: var(--text-subtle);
  font-size: 0.85rem;
}
.btn-action-icon:hover {
  color: var(--text-main);
}

.btn-delete-icon:hover {
  color: var(--rose);
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-emoji {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

/* ==========================================================================
   고정비 & 할부 탭 스타일
   ========================================================================== */
.fixed-banner {
  background: linear-gradient(135deg, var(--indigo-light) 0%, var(--bg-subtle) 100%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.fixed-banner-content h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.fixed-banner-content p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.fixed-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.fixed-item-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  position: relative;
}

.fixed-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.fixed-name-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fixed-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.fixed-payday {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.fixed-amount {
  font-family: var(--font-num);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--slate);
}

/* 할부 진행도 바 */
.installment-progress-box {
  background-color: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.installment-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 700;
}

.installment-bar-track {
  height: 6px;
  background-color: var(--border-color);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.installment-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #6366f1);
  border-radius: var(--radius-full);
}

.installment-remain {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.fixed-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px dashed var(--border-color);
  padding-top: 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ==========================================================================
   설정 및 백업 패널
   ========================================================================== */
.settings-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 600px;
}

.setting-block {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
}

.setting-block h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.setting-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.budget-input-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ==========================================================================
   모달 공통
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  padding: 16px;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-window {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  transform: translateY(20px);
  transition: transform 0.2s ease;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-overlay.active .modal-window {
  transform: translateY(0);
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-close-btn {
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  padding: 4px;
}
.modal-close-btn:hover {
  color: var(--text-main);
}

.modal-form {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
}

.form-group input,
.form-group select {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-subtle);
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--border-focus);
  background-color: var(--bg-surface);
}

.form-row {
  display: flex;
  gap: 12px;
}

.flex-1 { flex: 1; }

.input-with-unit {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-unit input {
  width: 100%;
  padding-right: 36px;
}

.input-with-unit .unit {
  position: absolute;
  right: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

/* 할부 토글 스위치 */
.installment-toggle-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: var(--bg-subtle);
  padding: 10px 14px;
  border-radius: var(--radius-md);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-color);
  transition: .2s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--primary);
}

input:checked + .slider:before {
  transform: translateX(18px);
}

.toggle-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
}

.installment-fields.hidden {
  display: none;
}

/* ==========================================================================
   📋 아내 보고용 브리핑 모달 특화 스타일
   ========================================================================== */
.briefing-modal-window {
  max-width: 650px;
}

.briefing-sheet {
  padding: 24px;
  background-color: var(--bg-surface);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.briefing-header {
  text-align: center;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 16px;
}

.briefing-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--primary);
  background-color: var(--primary-light);
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 6px;
}

.briefing-header h2 {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.briefing-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.briefing-comment-card {
  background: linear-gradient(135deg, #f0fdf4 0%, #e0f2fe 100%);
  border: 1px solid #bae6fd;
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex;
  gap: 14px;
}

body.dark-theme .briefing-comment-card {
  background: linear-gradient(135deg, #064e3b 0%, #0c4a6e 100%);
  border-color: #0369a1;
}

.comment-icon {
  font-size: 1.8rem;
}

.comment-headline {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
}

.comment-body {
  font-size: 0.86rem;
  color: var(--text-main);
  line-height: 1.5;
}

.briefing-breakdown-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 600px) {
  .briefing-breakdown-grid {
    grid-template-columns: 1fr;
  }
}

.briefing-box {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  background-color: var(--bg-subtle);
}

.box-head {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.box-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  display: block;
  margin-bottom: 2px;
}

.box-head h3 {
  font-family: var(--font-num);
  font-size: 1.2rem;
  font-weight: 800;
}

.briefing-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.briefing-list-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
}

.briefing-list-item .item-title {
  color: var(--text-main);
  font-weight: 600;
}

.briefing-list-item .item-val {
  font-family: var(--font-num);
  font-weight: 700;
}

.briefing-total-bar {
  background-color: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  justify-content: space-around;
  text-align: center;
  border: 1px solid var(--border-color);
}

.stat-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
}

.stat-num {
  font-family: var(--font-num);
  font-size: 1.15rem;
  font-weight: 800;
}

.briefing-footer-note {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding-top: 8px;
}

.briefing-actions {
  padding: 16px 24px;
  background-color: var(--bg-subtle);
  border-top: 1px solid var(--border-color);
}

/* 토스트 알림 */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background-color: #0f172a;
  color: #ffffff;
  padding: 12px 24px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-xl);
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 200;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(20px);
  pointer-events: none;
}

/* 빠른 템플릿 칩 */
.preset-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.preset-chip {
  padding: 5px 10px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  transition: all 0.15s ease;
}

.preset-chip:hover {
  background-color: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

/* 금액 빠른 증액 칩 */
.quick-amt-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.quick-amt-btn {
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.74rem;
  font-weight: 700;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.quick-amt-btn:hover {
  background-color: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.quick-amt-reset {
  color: var(--rose);
}
.quick-amt-reset:hover {
  background-color: var(--rose-light);
  border-color: var(--rose);
}

/* 클라우드 실시간 동기화 뱃지 */
.cloud-sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-main);
  transition: all 0.2s ease;
}

.sync-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--emerald);
  box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.7);
  animation: pulse-green 2s infinite;
}

.cloud-sync-badge.syncing .sync-pulse-dot {
  background-color: var(--amber);
  animation: pulse-amber 0.8s infinite;
}

.cloud-sync-badge.offline .sync-pulse-dot {
  background-color: var(--slate);
  animation: none;
}

.sync-detail-text {
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.sync-detail-text[data-status="synced"] { color: var(--emerald); }
.sync-detail-text[data-status="offline"] { color: var(--rose); }
.sync-detail-text[data-status="syncing"] { color: var(--amber); }

@keyframes pulse-green {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(5, 150, 105, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(5, 150, 105, 0); }
}

@keyframes pulse-amber {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(217, 119, 6, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(217, 119, 6, 0); }
}

/* ==========================================================================
   📱 모바일 원터치 카테고리 & 결제수단 칩 (One-Touch Chips UI)
   ========================================================================== */
.category-chip-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 6px;
}

.category-select-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 6px;
  background: var(--bg-subtle);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.category-select-chip .chip-icon {
  font-size: 1.05rem;
}

.category-select-chip:hover {
  background: var(--bg-surface);
  border-color: var(--primary-light);
  color: var(--text-main);
}

.category-select-chip:active {
  transform: scale(0.96);
}

.category-select-chip.active {
  background: var(--primary-subtle);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.15);
}

/* 결제수단 원터치 칩 */
.payment-chip-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 6px;
}

.payment-select-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 9px 4px;
  background: var(--bg-subtle);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.payment-select-chip:hover {
  background: var(--bg-surface);
  border-color: var(--emerald);
  color: var(--text-main);
}

.payment-select-chip:active {
  transform: scale(0.96);
}

.payment-select-chip.active {
  background: #ecfdf5;
  border-color: var(--emerald);
  color: var(--emerald);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.15);
}

/* 다크모드 대응 */
body.dark-theme .category-select-chip.active {
  background: rgba(37, 99, 235, 0.25);
  border-color: #60a5fa;
  color: #93c5fd;
}

body.dark-theme .payment-select-chip.active {
  background: rgba(16, 185, 129, 0.25);
  border-color: #34d399;
  color: #6ee7b7;
}

@media (max-width: 480px) {
  .category-chip-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .category-select-chip {
    padding: 8px 4px;
    font-size: 0.78rem;
    gap: 4px;
  }
  .category-select-chip .chip-icon {
    font-size: 0.95rem;
  }
  .payment-chip-row {
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
  }
  .payment-select-chip {
    padding: 7px 2px;
    font-size: 0.74rem;
  }
}

/* ==========================================================================
   📱 모바일 스마트 플로팅 지출 등록 버튼 (Smart Scroll FAB)
   ========================================================================== */
.mobile-fab {
  position: fixed;
  bottom: 24px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 22px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-full);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.4), 0 2px 6px rgba(0, 0, 0, 0.08);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  z-index: 90;
  transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease, box-shadow 0.2s ease;
  will-change: transform, opacity;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.mobile-fab .fab-icon {
  font-size: 1.15rem;
  transition: transform 0.2s ease;
}

.mobile-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.5);
}

.mobile-fab:active {
  transform: scale(0.94);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* 📜 스크롤 다운 시 부드럽게 아래로 슬라이드 아웃 */
.mobile-fab.fab-hidden {
  transform: translateY(90px) scale(0.85);
  opacity: 0;
  pointer-events: none;
}

body.modal-open .mobile-fab {
  opacity: 0;
  transform: translateY(90px) scale(0.85);
  pointer-events: none;
}

@media (max-width: 600px) {
  .app-header {
    position: static;
  }

  .header-container,
  .main-layout {
    padding-left: 16px;
    padding-right: 16px;
  }

  .tab-buttons {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }

  .tab-btn {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .tab-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .fixed-cards-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .tx-item-row {
    align-items: flex-start;
    gap: 10px;
  }

  .tx-left,
  .tx-details {
    min-width: 0;
  }

  .tx-left {
    flex: 1;
  }

  .tx-title,
  .tx-memo-tag {
    overflow-wrap: anywhere;
  }

  .tx-meta {
    flex-wrap: wrap;
    gap: 4px 6px;
  }

  .tx-right {
    flex: 0 0 auto;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
  }

  .tx-amount {
    font-size: 0.95rem;
    white-space: nowrap;
  }

  .briefing-actions {
    gap: 8px;
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .mobile-fab {
    bottom: 20px;
    right: 16px;
    padding: 12px 18px;
    font-size: 0.88rem;
  }
}
/* ========================================================================== */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .app-header,
  .summary-grid,
  .analytics-section,
  .content-tabs-section,
  .no-print,
  .modal-close-btn,
  .toast {
    display: none !important;
  }

  .modal-overlay {
    position: static !important;
    background: transparent !important;
    backdrop-filter: none !important;
    padding: 0 !important;
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  .modal-window {
    box-shadow: none !important;
    border: none !important;
    max-width: 100% !important;
  }

  .briefing-sheet {
    padding: 0 !important;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 24px !important;
  }
}
