*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #3B82F6;
  --primary-dark: #2563EB;
  --danger: #EF4444;
  --success: #10B981;
  --bg: #F1F5F9;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --text: #1E293B;
  --text-muted: #64748B;
  --sidebar-w: 220px;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

/* ── 사이드바 ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  box-shadow: var(--shadow);
}
.sidebar-logo {
  font-size: 1.25rem;
  font-weight: 700;
  padding: 8px 8px 20px;
  color: var(--primary);
}
.nav-links { list-style: none; flex: 1; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 2px;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active { background: #EFF6FF; color: var(--primary); font-weight: 600; }
.nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }

.sidebar-footer { border-top: 1px solid var(--border); padding-top: 12px; }
.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  margin-bottom: 8px;
}
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--user-color, var(--primary));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}
.user-name { font-weight: 600; font-size: 0.9rem; }
.logout-btn {
  display: block;
  text-align: center;
  padding: 6px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  background: var(--bg);
}
.logout-btn:hover { color: var(--danger); }

/* ── 메인 컨텐츠 ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 28px;
  max-width: 1200px;
  padding-bottom: 80px;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h1 { font-size: 1.6rem; font-weight: 700; }
.page-subtitle { color: var(--text-muted); margin-top: 4px; font-size: 0.95rem; }

/* ── 버튼 ── */
.btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover { opacity: .9; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── 카드 ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-header h2 { font-size: 1rem; font-weight: 600; }
.card-link { color: var(--primary); text-decoration: none; font-size: 0.85rem; }
.card-body { padding: 16px 20px; }

/* ── 폼 ── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s;
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

/* ── 알림 ── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.alert-error { background: #FEF2F2; color: #DC2626; border: 1px solid #FECACA; }

/* ── 인증 페이지 ── */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #EFF6FF 0%, #F0FDF4 100%);
  margin: 0;
}
.auth-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 10px 40px rgba(0,0,0,.12);
}
.auth-logo { font-size: 3rem; text-align: center; margin-bottom: 12px; }
.auth-title { font-size: 1.5rem; font-weight: 700; text-align: center; margin-bottom: 6px; }
.auth-subtitle { color: var(--text-muted); text-align: center; margin-bottom: 24px; font-size: 0.9rem; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }

/* ── 대시보드 ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.stat-icon { font-size: 1.8rem; margin-bottom: 8px; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.event-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.event-item {
  display: flex;
  align-items: center;
  gap: 10px;
}
.event-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.event-info { flex: 1; }
.event-title { font-weight: 600; font-size: 0.9rem; display: block; }
.event-date { font-size: 0.8rem; color: var(--text-muted); }
.event-creator { font-size: 0.8rem; color: var(--text-muted); }

.mini-gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.mini-photo { display: block; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--bg); }
.mini-photo img { width: 100%; height: 100%; object-fit: cover; }
.mini-video { display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }

.empty-state { color: var(--text-muted); font-size: 0.9rem; padding: 16px 0; }
.empty-page { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 4rem; margin-bottom: 16px; }

/* ── 갤러리 ── */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.gallery-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  background: var(--border);
}
.gallery-item img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .3s;
}
.gallery-item:hover img { transform: scale(1.05); }
.gallery-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent 40%, rgba(0,0,0,.7));
  opacity: 0;
  transition: opacity .2s;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  color: #fff;
}
.gallery-item:hover .gallery-overlay { opacity: 1; }
.gallery-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 4px; }
.gallery-meta { font-size: 0.75rem; opacity: .8; display: flex; justify-content: space-between; }
.delete-btn {
  position: absolute;
  top: 8px; right: 8px;
  background: rgba(0,0,0,.5);
  border: none;
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  color: #fff;
  font-size: 0.9rem;
}
.video-thumb {
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #1E293B;
  color: #fff;
}
.video-icon { font-size: 2rem; }
.video-label { font-size: 0.75rem; opacity: .7; }

/* ── 업로드 ── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  transition: border-color .15s, background .15s;
  margin-bottom: 16px;
}
.drop-zone.drag-over { border-color: var(--primary); background: #EFF6FF; }
.drop-icon { font-size: 2.5rem; margin-bottom: 8px; }
.drop-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 8px; }
.file-label { cursor: pointer; }

.upload-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.preview-item {
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
}
.preview-item img { width: 100%; height: 100%; object-fit: cover; }
.preview-video {
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: #1E293B;
  color: #fff;
}
.preview-more {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--text-muted);
  font-size: 1.1rem;
}
.upload-progress { margin-top: 12px; }
.progress-bar { background: var(--border); border-radius: 4px; height: 6px; margin-bottom: 6px; }
.progress-fill { background: var(--primary); height: 100%; border-radius: 4px; width: 100%; animation: progress 1s ease infinite alternate; }
@keyframes progress { from { opacity: .6; } to { opacity: 1; } }
.progress-text { font-size: 0.85rem; color: var(--text-muted); }

/* ── 라이트박스 ── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.9);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 95vw; max-height: 85vh; object-fit: contain; border-radius: 8px; }
.lightbox-title { color: #fff; font-size: 1rem; }

/* ── 캘린더 ── */
.calendar-container { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden; }
.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.calendar-nav h2 { font-size: 1.1rem; font-weight: 600; }
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.cal-header {
  padding: 10px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.cal-day {
  min-height: 90px;
  padding: 6px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  cursor: default;
}
.cal-day:nth-child(7n) { border-right: none; }
.cal-day.today { background: #EFF6FF; }
.cal-day.empty { background: var(--bg); }
.cal-day-num { font-size: 0.85rem; font-weight: 600; display: block; margin-bottom: 4px; }
.cal-event {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
  cursor: pointer;
}
.cal-more { font-size: 0.7rem; color: var(--text-muted); }

.event-list-panel {
  margin-top: 20px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px 20px;
}
.event-list-panel h3 { font-size: 1rem; margin-bottom: 12px; }
.event-list-panel .event-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.event-list-panel .event-item:last-child { border-bottom: none; }

.color-picker { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.color-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform .15s;
}
.color-dot:hover { transform: scale(1.2); }
.color-dot.selected { border-color: var(--text); transform: scale(1.15); }

/* ── 메모 ── */
.notes-layout { display: grid; grid-template-columns: 260px 1fr; gap: 0; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); min-height: 70vh; overflow: hidden; }
.notes-sidebar { border-right: 1px solid var(--border); overflow-y: auto; }
.notes-list { list-style: none; }
.notes-item {
  padding: 14px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.notes-item:hover { background: var(--bg); }
.notes-item.active { background: #EFF6FF; border-left: 3px solid var(--primary); }
.notes-item-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notes-item-meta { font-size: 0.75rem; color: var(--text-muted); }

.notes-editor { display: flex; flex-direction: column; }
.notes-editor-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.notes-title-input {
  flex: 1;
  border: none;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 0;
  background: transparent;
  outline: none;
  color: var(--text);
}
.notes-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.notes-saved { font-size: 0.8rem; color: var(--success); }
.notes-content {
  flex: 1;
  border: none;
  padding: 20px;
  font-size: 0.95rem;
  line-height: 1.7;
  resize: none;
  background: transparent;
  outline: none;
  color: var(--text);
  font-family: inherit;
  min-height: 400px;
}
.notes-empty { display: flex; align-items: center; justify-content: center; color: var(--text-muted); height: 100%; }

/* ── 채팅 ── */
.chat-layout { display: flex; flex-direction: column; height: calc(100vh - 56px); max-height: 800px; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden; }
.chat-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.chat-header h1 { font-size: 1.1rem; font-weight: 600; }
.online-badge { font-size: 0.8rem; color: var(--text-muted); }

.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.chat-msg { display: flex; gap: 10px; align-items: flex-end; max-width: 70%; }
.chat-msg-me { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem;
  color: #fff;
  flex-shrink: 0;
}
.msg-body { display: flex; flex-direction: column; gap: 2px; }
.chat-msg-me .msg-body { align-items: flex-end; }
.msg-name { font-size: 0.75rem; font-weight: 600; margin-bottom: 2px; }
.msg-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 0.9rem;
  line-height: 1.5;
  background: var(--bg);
  border: 1px solid var(--border);
  word-break: break-word;
  max-width: 100%;
}
.chat-msg-me .msg-bubble { background: var(--primary); color: #fff; border-color: var(--primary); }
.msg-time { font-size: 0.7rem; color: var(--text-muted); padding: 0 4px; }
.chat-system { text-align: center; font-size: 0.8rem; color: var(--text-muted); padding: 4px 12px; background: var(--bg); border-radius: 20px; align-self: center; }

.chat-input-area {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 0.9rem;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  font-family: inherit;
  line-height: 1.4;
  transition: border-color .15s;
}
.chat-input:focus { outline: none; border-color: var(--primary); }
.chat-send { border-radius: 20px; padding: 10px 20px; }

/* ── 구성원 관리 ── */
.member-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.member-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.member-item:last-child { border-bottom: none; }
.member-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: 1rem;
  flex-shrink: 0;
}
.member-info { flex: 1; }
.member-info strong { display: block; font-size: 0.95rem; }
.member-username { font-size: 0.8rem; color: var(--text-muted); }
.badge-admin { background: var(--primary); color: #fff; font-size: 0.7rem; padding: 2px 8px; border-radius: 20px; margin-left: 6px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ── 모달 ── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.open { display: flex; }
.modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-video { max-width: 800px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text-muted);
  padding: 4px;
}
.modal-body { padding: 20px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

/* ── 모바일 하단 네비 ── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 0 env(safe-area-inset-bottom, 8px);
  z-index: 100;
}
.bn-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  flex: 1;
  padding: 4px;
}
.bn-item.active { color: var(--primary); }
.bn-item span:first-child { font-size: 1.3rem; }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .bottom-nav { display: flex; }
  .main-content { margin-left: 0; padding: 16px; padding-bottom: 90px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .notes-layout { grid-template-columns: 1fr; }
  .notes-sidebar { max-height: 200px; border-right: none; border-bottom: 1px solid var(--border); }
  .chat-layout { height: calc(100vh - 130px); }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

  /* 캘린더 모바일 */
  .cal-day { min-height: 54px; padding: 3px; }
  .cal-day-num { font-size: 0.75rem; }
  .cal-event { font-size: 0.6rem; padding: 1px 4px; }
  .calendar-nav h2 { font-size: 0.95rem; }

  /* 인증 페이지 */
  .auth-card { padding: 28px 20px; }

  /* iOS 줌 방지: 포커스 시 폰트 최소 16px */
  .form-group input,
  .form-group textarea,
  .form-group select,
  .chat-input { font-size: 16px; }

  /* 모달 */
  .modal { padding: 12px; }
  .modal-content { max-height: 95vh; }

  /* 버튼 터치 영역 확대 */
  .btn { min-height: 40px; }

  /* 예산 모바일 */
  .budget-main-grid { grid-template-columns: 1fr !important; }
  .budget-summary-grid { grid-template-columns: 1fr 1fr !important; gap: 10px !important; margin-bottom: 16px !important; }
  .form-row-2 { grid-template-columns: 1fr !important; }

  /* 페이지 헤더 세로 정렬 */
  .page-header { flex-direction: column !important; align-items: stretch !important; gap: 10px; margin-bottom: 16px; overflow: hidden; }
  .page-header h1 { font-size: 1.2rem; }
  .page-subtitle { font-size: 0.82rem; }
  .month-nav { justify-content: center; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; width: 100%; box-sizing: border-box; }
  .month-label { font-size: 1rem; text-align: center; flex: 1; }

  /* 요약 카드 컴팩트 */
  .summary-card { padding: 12px 8px; }
  .summary-icon { font-size: 1.2rem; margin-bottom: 4px; }
  .summary-value { font-size: 0.82rem !important; }
  .summary-label { font-size: 0.72rem; }

  /* 거래 목록: 테이블 숨기고 카드 표시 */
  #expenseTable { display: none !important; }
  #expenseCards { display: flex !important; flex-direction: column; gap: 8px; padding: 12px; }
  #expenseListWrap { min-height: 120px; overflow-x: visible !important; }

  /* 데스크톱 추가 버튼 숨김 */
  .desktop-add-btn { display: none !important; }

  /* FAB 표시 */
  .add-fab { display: flex !important; }

  /* Claude 모달 하단 시트 */
  .claude-modal-overlay { padding: 0 !important; align-items: flex-end !important; }
  .claude-modal-card { max-width: 100% !important; border-radius: 16px 16px 0 0 !important; max-height: 92vh !important; }

  /* 안전 영역 */
  .main-content { padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px)) !important; }
}

/* ── 예산/지출 관리 ── */
.budget-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.summary-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
  border-top: 4px solid var(--card-color, var(--primary));
}
.summary-icon { font-size: 1.6rem; margin-bottom: 6px; }
.summary-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--card-color, var(--primary));
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.summary-label { font-size: 0.8rem; color: var(--text-muted); }

.budget-main-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
}
.budget-tools { display: flex; flex-direction: column; gap: 0; }

.month-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}
.month-label {
  font-size: 1.1rem;
  font-weight: 700;
  min-width: 110px;
  text-align: center;
}

/* 거래 테이블 */
.budget-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
#expenseListWrap { min-height: 320px; overflow-x: auto; }
.budget-table th {
  padding: 10px 12px;
  background: var(--bg);
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.budget-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.budget-table tr:last-child td { border-bottom: none; }
.budget-table tr:hover td { background: var(--bg); }

.type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
}

.filter-select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  background: var(--surface);
  color: var(--text);
}

/* 카테고리 진행 막대 */
.category-breakdown { display: flex; flex-direction: column; gap: 12px; }
.cat-row { display: flex; flex-direction: column; gap: 4px; }
.cat-info {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px;
}
.cat-name { font-weight: 600; font-size: 0.88rem; }
.cat-amounts { font-size: 0.8rem; color: var(--text-muted); }
.over-badge {
  display: inline-block;
  background: #FEF2F2;
  color: #DC2626;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.75rem;
  font-weight: 700;
}
.progress-track {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .4s ease;
}

/* Claude 결과 */
.claude-result {
  margin-top: 16px;
  max-height: 70vh;
  overflow-y: auto;
  border-radius: 12px;
  border: 1px solid #C7D2FE;
  background: linear-gradient(135deg, #EEF2FF 0%, #F8FAFF 100%);
  font-size: 0.88rem;
  line-height: 1.75;
  color: var(--text);
}

/* 마크다운 리포트 래퍼 */
.claude-report {
  padding: 20px 22px;
}
.claude-report h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #3730A3;
  margin: 18px 0 8px;
  padding-bottom: 4px;
  border-bottom: 2px solid #C7D2FE;
}
.claude-report h3:first-child { margin-top: 0; }
.claude-report p { margin: 6px 0; }
.claude-report strong { color: #1E1B4B; }
.claude-report ul, .claude-report ol {
  padding-left: 18px;
  margin: 6px 0;
}
.claude-report li { margin: 4px 0; }
.claude-report hr {
  border: none;
  border-top: 1px solid #C7D2FE;
  margin: 14px 0;
}
.claude-report table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 0.85rem;
}
.claude-report th {
  background: #4F46E5;
  color: #fff;
  padding: 7px 10px;
  text-align: left;
  font-weight: 600;
}
.claude-report td {
  padding: 7px 10px;
  border-bottom: 1px solid #E0E7FF;
}
.claude-report tr:nth-child(even) td { background: #EEF2FF; }
.claude-report blockquote {
  margin: 10px 0;
  padding: 10px 14px;
  background: #E0E7FF;
  border-left: 4px solid #6366F1;
  border-radius: 0 8px 8px 0;
  font-size: 0.87rem;
  color: #3730A3;
}

/* 로딩 점 애니메이션 */
.claude-loading {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 20px 22px;
}
.claude-loading span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #6366F1;
  animation: claudeBounce 1.2s infinite ease-in-out;
}
.claude-loading span:nth-child(2) { animation-delay: 0.2s; }
.claude-loading span:nth-child(3) { animation-delay: 0.4s; }
@keyframes claudeBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.claude-error { padding: 16px; color: var(--danger); font-size: 0.87rem; }

/* 동기화 상태 */
.sync-status {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
  display: none;
}

/* 셋업 안내 */
.setup-guide {
  background: var(--bg);
  border-radius: 8px;
  padding: 12px;
  border: 1px solid var(--border);
}
.setup-guide code {
  background: var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.78rem;
}

/* 추가 모달 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
}
.modal-close:hover { color: var(--text); }
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ── Claude 분석 모달 ─────────────────────────────────── */
.claude-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.claude-modal-card {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 860px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,0.25);
  overflow: hidden;
}
.claude-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid #E0E7FF;
  background: linear-gradient(135deg, #EEF2FF, #fff);
  flex-shrink: 0;
}
.claude-modal-header h2 {
  font-size: 1.1rem;
  color: #3730A3;
  margin: 0;
}
.claude-modal-body {
  overflow-y: auto;
  flex: 1;
  padding: 0;
}
.claude-modal-body .claude-result {
  border: none;
  background: none;
  max-height: none;
  border-radius: 0;
}
.claude-modal-body .claude-report {
  padding: 24px 28px;
}
.claude-modal-body .claude-loading {
  padding: 40px;
  justify-content: center;
}
.claude-modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: #6B7280;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
}
.claude-modal-close:hover { background: #F3F4F6; color: #111; }
@media (max-width: 600px) {
  .claude-modal-card { max-height: 95vh; border-radius: 12px; }
  .claude-modal-body .claude-report { padding: 16px 18px; }
}

/* ── 거래 카드 스타일 (항상 정의, 768px에서 표시) ── */
#expenseCards { display: none; }

.expense-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid #64748B;
  border-radius: 10px;
  padding: 12px 12px 10px;
}
.ec-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.ec-left { display: flex; flex-direction: column; gap: 2px; }
.ec-date { font-size: 0.78rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.ec-cat { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.ec-amount { font-size: 1.05rem; font-weight: 700; white-space: nowrap; flex-shrink: 0; }
.ec-bot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ec-desc {
  font-size: 0.78rem; color: var(--text-muted);
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ec-writer { font-size: 0.75rem; color: var(--text-muted); margin-left: auto; }
.ec-del {
  background: none; border: none; font-size: 0.85rem;
  cursor: pointer; padding: 4px 6px; border-radius: 6px;
  color: var(--text-muted); flex-shrink: 0;
}
.ec-del:active { background: #FEE2E2; color: var(--danger); }
.ec-hidden { display: none !important; }
.ec-collapse-header-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}
.ec-collapse-header-btn:active { background: var(--bg); }
.ec-expand-btn {
  display: block;
  width: calc(100% - 24px);
  margin: 4px 12px 12px;
  padding: 10px;
  background: none;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, color 0.15s;
}
.ec-expand-btn:active { background: var(--bg); color: var(--primary); }

/* ── FAB (항상 정의, 768px에서만 표시) ── */
.add-fab {
  display: none;
  align-items: center;
  justify-content: center;
  position: fixed;
  right: 20px;
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 1.6rem; font-weight: 300;
  border: none;
  box-shadow: 0 4px 16px rgba(59,130,246,0.45);
  cursor: pointer; z-index: 500;
  transition: transform 0.15s, box-shadow 0.15s;
}
.add-fab:active { transform: scale(0.93); box-shadow: 0 2px 8px rgba(59,130,246,0.35); }
