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

:root {
  --primary: #0f172a;
  --primary-light: #1e293b;
  --primary-mid: #334155;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-bg: #eef2ff;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --sidebar-w: 224px;
  --income-color: #10b981;
  --income-bg: #ecfdf5;
  --expense-color: #f43f5e;
  --expense-bg: #fff1f2;
  --neutral: #6366f1;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --radius: 8px;
  --radius-sm: 5px;
}

body {
  font-family: 'Malgun Gothic', 'Apple SD Gothic Neo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

#app { display: flex; height: 100vh; overflow: hidden; }

/* ─── SIDEBAR ─────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid rgba(255,255,255,0.04);
}

.sidebar-header {
  padding: 22px 18px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.logo {
  font-size: 20px;
  font-weight: 800;
  color: var(--accent-light);
  letter-spacing: 2px;
  font-family: 'Segoe UI', Arial, sans-serif;
}

.company-name {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  margin-top: 5px;
  letter-spacing: 0.3px;
}

.nav-menu { list-style: none; padding: 10px 8px; flex: 1; overflow-y: auto; }

.nav-item {
  padding: 9px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: rgba(255,255,255,0.6);
  border-radius: 6px;
  margin-bottom: 2px;
  transition: background 0.12s, color 0.12s;
}

.nav-item:hover { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.9); }
.nav-item.active { background: rgba(99,102,241,0.25); color: #fff; font-weight: 600; }
.nav-item.active .nav-icon { color: var(--accent-light); }
.nav-icon { width: 16px; text-align: center; font-size: 14px; opacity: 0.85; }
.nav-divider { border-top: 1px solid rgba(255,255,255,0.07); margin: 6px 0; }

/* ─── MAIN ─────────────────────────────────────────────── */
#main-content { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.page { display: none; flex: 1; }
.page.active { display: block; }

/* ─── PAGE HEADER ──────────────────────────────────────── */
.page-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.page-header h1 { font-size: 17px; font-weight: 700; color: var(--text); letter-spacing: -0.3px; }
.page-header-actions { display: flex; gap: 8px; align-items: center; }
.page-body { padding: 24px 28px; }

/* ─── CARDS ────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.card-title { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; font-weight: 500; letter-spacing: 0.2px; text-transform: uppercase; }
.card-value { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }
.card-value.income { color: var(--income-color); }
.card-value.expense { color: var(--expense-color); }
.card-value.balance { color: var(--neutral); }

/* Stat cards with left accent line */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: 3px 0 0 3px;
}
.stat-card.income::before { background: var(--income-color); }
.stat-card.expense::before { background: var(--expense-color); }
.stat-card.neutral::before { background: var(--accent); }
.stat-card.gray::before { background: var(--text-subtle); }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat-grid-3 { grid-template-columns: repeat(3, 1fr); }

/* ─── TABLES ────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

thead th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-size: 12px;
  letter-spacing: 0.2px;
}

tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  white-space: nowrap;   /* 셀이 좁아져도 글자 단위로 줄바꿈되지 않도록 — 넘치면 .table-wrap 가로 스크롤 */
}

tbody tr:hover { background: #f8faff; }
tbody tr:last-child td { border-bottom: none; }
.amount-in { color: var(--income-color); font-weight: 600; }
.amount-out { color: var(--expense-color); font-weight: 600; }
.amount-bal { color: var(--neutral); font-weight: 500; }

/* ─── BUTTONS ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.12s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(99,102,241,0.3);
}
.btn-primary:hover { background: #4f46e5; box-shadow: 0 2px 4px rgba(99,102,241,0.4); }

.btn-success { background: var(--income-color); color: #fff; }
.btn-success:hover { background: #059669; }

.btn-danger { background: var(--expense-color); color: #fff; }
.btn-danger:hover { background: #e11d48; }

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--surface-2); color: var(--text); border-color: #cbd5e1; }

.btn-ghost { background: transparent; color: var(--text-muted); border: none; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 4px; }

/* ─── FORMS ─────────────────────────────────────────────── */
.form-row { display: flex; gap: 14px; margin-bottom: 14px; align-items: flex-end; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 12px; color: var(--text-muted); font-weight: 600; letter-spacing: 0.2px; }

.form-group input,
.form-group select,
.form-group textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

.form-group.flex-1 { flex: 1; }
.form-group textarea { resize: vertical; min-height: 80px; }

/* ─── FILTER BAR ────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: var(--shadow-sm);
}

.filter-bar label { font-size: 12px; color: var(--text-muted); font-weight: 500; }

.filter-bar input,
.filter-bar select {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-2);
}

.filter-bar input:focus,
.filter-bar select:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

.filter-sep { flex: 1; }

/* ─── BADGES ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1px;
  white-space: nowrap;
}

.badge-income { background: var(--income-bg); color: #059669; }
.badge-expense { background: var(--expense-bg); color: #e11d48; }
.badge-neutral { background: var(--accent-bg); color: var(--accent); }
.badge-gray { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.badge-purple { background: #f5f3ff; color: #7c3aed; }
.badge-blue { background: #eff6ff; color: #2563eb; }
.badge-amber { background: #fffbeb; color: #d97706; }

/* ─── TABS ───────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  gap: 4px;
}

.tab {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: 6px 6px 0 0;
  font-weight: 500;
  transition: color 0.12s;
}

.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; background: transparent; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ─── MODAL ──────────────────────────────────────────────── */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#modal-overlay.hidden { display: none; }

#modal-container {
  background: var(--surface);
  border-radius: 12px;
  min-width: 520px;
  max-width: 860px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,0,0,0.05);
}

#modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

#modal-title { font-size: 15px; font-weight: 700; color: var(--text); }

#modal-close {
  background: var(--surface-2);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
}

#modal-close:hover { background: var(--border); color: var(--text); }
#modal-body { padding: 20px; overflow-y: auto; flex: 1; }
#modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ImportKit 가져오기 모달 */
.ik-help { font-size: 12.5px; color: var(--text-muted); line-height: 1.6; margin-bottom: 10px; }
.ik-help b { color: var(--text); }
.req-mark { color: var(--expense-color); font-weight: 700; }
.ik-cols { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.ik-col { font-size: 11.5px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.ik-col.req { background: var(--accent-bg); color: #3730a3; border-color: #c7d2fe; font-weight: 600; }
.ik-sheets { margin-top: 16px; }
.ik-or { display: flex; align-items: center; text-align: center; color: var(--text-subtle); font-size: 12px; margin-bottom: 10px; }
.ik-or::before, .ik-or::after { content: ''; flex: 1; border-top: 1px solid var(--border); }
.ik-or span { padding: 0 12px; }
.ik-sheet-row { display: flex; gap: 8px; }
.ik-sheet-row input { flex: 1; padding: 8px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; font-family: inherit; }
.ik-sheet-row input:focus { outline: none; border-color: var(--accent); }
.ik-sheet-help { font-size: 11.5px; color: var(--text-subtle); margin-top: 7px; line-height: 1.5; }
.ik-sheet-help b { color: var(--text-muted); }
@media (max-width: 768px) {
  #modal-container { min-width: 0; width: 94vw; }
  .ik-sheet-row { flex-wrap: wrap; }
  .ik-sheet-row input { flex: 1 1 100%; }
}

/* ─── TOAST ──────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  min-width: 220px;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255,255,255,0.1);
}

.toast.success { background: #064e3b; color: #6ee7b7; }
.toast.error { background: #881337; color: #fca5a5; }
.toast.info { background: #1e1b4b; color: #a5b4fc; }

@keyframes toastIn {
  from { transform: translateY(8px) scale(0.97); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

/* ─── CHARTS ─────────────────────────────────────────────── */
.chart-container { position: relative; }
.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }

/* ─── SECTION ────────────────────────────────────────────── */
.section { margin-bottom: 22px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-title { font-size: 14px; font-weight: 700; color: var(--text); letter-spacing: -0.2px; }

/* ─── STATUS BADGES ──────────────────────────────────────── */
.status-active { background: var(--income-bg); color: #059669; }
.status-closed { background: var(--surface-2); color: var(--text-muted); }
.status-pending { background: #fffbeb; color: #d97706; }

/* ─── PROGRESS BAR ───────────────────────────────────────── */
.progress-bar-wrap {
  background: var(--border);
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  transition: width 0.4s ease;
}

.progress-bar.over { background: linear-gradient(90deg, var(--expense-color), #fb7185); }

/* ─── UPLOAD AREA ────────────────────────────────────────── */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--surface-2);
}

.upload-area:hover,
.upload-area.drag-over {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.upload-icon { font-size: 28px; margin-bottom: 10px; opacity: 0.7; }
.upload-text { color: var(--text-muted); font-size: 13px; line-height: 1.6; }
.upload-text strong { color: var(--accent); }

/* ─── DOCUMENT CARDS ─────────────────────────────────────── */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }

.doc-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
  background: var(--surface);
}

.doc-card:hover { box-shadow: var(--shadow); border-color: #cbd5e1; }
.doc-card .doc-icon { font-size: 26px; margin-bottom: 8px; }
.doc-card .doc-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--text); }
.doc-card .doc-meta { font-size: 11px; color: var(--text-muted); line-height: 1.6; }

/* ─── MISC ───────────────────────────────────────────────── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mt-16 { margin-top: 16px; }
.mt-8 { margin-top: 8px; }
.flex { display: flex; }
.flex-gap { gap: 8px; }
.flex-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 32px; margin-bottom: 12px; opacity: 0.5; }

/* ─── SCROLLBAR ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ─── MATCHING ───────────────────────────────────────────── */
.matched { background: #f0fdf4 !important; }
.unmatched { background: #fff1f2 !important; }

/* ─── BUDGET TABLE ───────────────────────────────────────── */
.budget-table td.over-budget { color: var(--expense-color); font-weight: 700; }
.budget-category-row td { background: var(--surface-2); font-weight: 600; }

/* ─── LAYOUT HELPERS ─────────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ─── PERIOD FILTER BUTTONS ──────────────────────────────── */
.period-btn-group { display: flex; gap: 1px; }
.period-btn-group .btn { border-radius: 0; }
.period-btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.period-btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ─── IMPORT UNIFIED ─────────────────────────────────────── */
.import-log-item { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; border-radius: 6px; margin-bottom: 6px; font-size: 12px; }
.import-log-item.success { background: var(--income-bg); color: #065f46; }
.import-log-item.error { background: var(--expense-bg); color: #9f1239; }
.import-log-item.info { background: var(--accent-bg); color: #3730a3; }
.import-log-item.warning { background: #fffbeb; color: #92400e; }

/* ─── DIVIDER ────────────────────────────────────────────── */
hr.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ─── LOGIN GATE ─────────────────────────────────────────────
   auth-gate.js의 _show()가 el.style.display=''로 인라인 display:flex를
   지우므로, 중앙 정렬을 CSS로 선언해 display가 비워져도 유지되게 한다.
   (숨김은 _hide()가 인라인 display:none으로 처리 → 인라인이 우선 적용됨) */
#login-screen { display: flex; align-items: center; justify-content: center; }
#login-btn { display: flex; align-items: center; justify-content: center; gap: 8px; }

/* ─── PRETENDARD + MODERN FINTECH UI REFRESH ───────────────── */
:root {
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.04), 0 1px 3px rgba(15,23,42,0.06);
  --shadow: 0 4px 14px -3px rgba(15,23,42,0.10), 0 2px 6px -2px rgba(15,23,42,0.05);
  --shadow-lg: 0 12px 28px -6px rgba(15,23,42,0.14), 0 6px 12px -4px rgba(15,23,42,0.06);
  --font-sans: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}
body { font-family: var(--font-sans); letter-spacing: -0.01em; }
.logo { font-family: var(--font-sans); }
/* 숫자 자릿수 정렬(금융앱 표준) */
.num, .card-value, .amount-in, .amount-out, .amount-bal,
table td.num, input[type="number"], input[type="date"] {
  font-variant-numeric: tabular-nums; font-feature-settings: "tnum";
}
/* 카드 모서리·그림자 현대화 + 인터랙션 */
.card { border-radius: var(--radius); }
.stat-card { border-radius: var(--radius); transition: box-shadow .16s ease, transform .16s ease; }
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-card::before { width: 4px; }
.card-value { letter-spacing: -0.6px; }
.page-header h1 { letter-spacing: -0.4px; }
.btn { font-weight: 600; }
thead th { text-transform: none; }

/* ─── 사이드바 하단 데이터 최신성 ───────────────────────────── */
.sidebar-footer { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,0.06); }
.data-freshness { display: flex; align-items: center; gap: 8px; font-size: 11px; color: rgba(255,255,255,0.55); line-height: 1.45; }
.data-freshness b { color: #fff; font-weight: 600; }
.df-dot { width: 7px; height: 7px; border-radius: 50%; background: #10b981; flex-shrink: 0; box-shadow: 0 0 0 3px rgba(16,185,129,0.18); }
.data-freshness[data-status="warn"]  .df-dot { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,0.18); }
.data-freshness[data-status="stale"] .df-dot { background: #f43f5e; box-shadow: 0 0 0 3px rgba(244,63,94,0.18); }
.data-freshness[data-status="empty"] .df-dot { background: #94a3b8; box-shadow: none; }
.df-ago { color: rgba(255,255,255,0.42); }
.data-freshness[style*="pointer"]:hover { opacity: 0.85; }

/* 데이터 최신 현황 모달 */
.df-modal { font-size: 13px; }
.df-sec-title { font-weight: 700; font-size: 12px; color: var(--text-muted); margin: 2px 0 6px; }
.df-row { padding: 9px 0; border-bottom: 1px solid var(--border-light); }
.df-row:last-child { border-bottom: none; }
.df-row-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.df-row-name { font-weight: 600; font-size: 13.5px; }
.df-row-count { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.df-row-sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.df-row-sub b { color: var(--text); font-weight: 600; }
.df-row-ago { font-weight: 600; margin-left: 4px; }
.df-row-ago.fresh { color: var(--income-color); }
.df-row-ago.warn { color: #d97706; }
.df-row-ago.stale { color: var(--expense-color); }
.df-empty { font-size: 12px; color: var(--text-subtle); padding: 8px 0; }
.df-modal-foot { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-subtle); text-align: right; }

/* ─── 월간 리포트 ───────────────────────────────────────────── */
.rp-month-select { padding: 5px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; background: #fff; color: var(--text); cursor: pointer; }
.rp-coverage { font-size: 12px; color: var(--text-muted); margin: -6px 0 16px; }
.rp-coverage b { color: var(--text); font-weight: 600; }
.rp-balance-card { display: flex; align-items: center; justify-content: space-around; gap: 12px; margin-bottom: 20px; padding: 16px 22px; }
.rp-bal-item { text-align: center; flex: 1; }
.rp-bal-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.rp-bal-val { font-size: 19px; font-weight: 700; letter-spacing: -0.4px; }
.rp-bal-arrow { color: var(--text-subtle); font-size: 18px; flex-shrink: 0; }
@media (max-width: 768px) {
  .rp-balance-card { flex-wrap: wrap; padding: 14px; }
  .rp-bal-arrow { display: none; }
  .rp-bal-val { font-size: 16px; }
}
.rp-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.rp-sec-title { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.rp-dot { width: 9px; height: 9px; border-radius: 50%; }
.rp-dot.in { background: var(--income-color); }
.rp-dot.out { background: var(--expense-color); }

.rp-delta { display: inline-block; font-size: 11px; margin-top: 6px; font-weight: 600; }
.rp-delta.good { color: var(--income-color); }
.rp-delta.bad  { color: var(--expense-color); }
.rp-delta.flat { color: var(--text-subtle); }

.rp-issues-card { margin-bottom: 20px; }
.rp-issue-list { display: flex; flex-direction: column; gap: 8px; }
.rp-issue { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; padding: 9px 12px; border-radius: var(--radius-sm); line-height: 1.5; }
.rp-issue b { font-weight: 700; }
.rp-issue.good { background: var(--income-bg); color: #065f46; }
.rp-issue.bad  { background: var(--expense-bg); color: #9f1239; }
.rp-issue.warn { background: #fffbeb; color: #92400e; }
.rp-issue-ic { font-weight: 700; flex-shrink: 0; }

.rp-bar-row { margin-bottom: 14px; }
.rp-bar-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; gap: 8px; }
.rp-bar-label { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.rp-cat-dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; flex-shrink: 0; }
.rp-bar-amt { font-size: 13px; font-weight: 600; white-space: nowrap; }
.rp-bar-pct { font-size: 11px; color: var(--text-subtle); margin-left: 4px; font-weight: 500; }
.rp-bar-track { height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.rp-bar-fill { height: 100%; border-radius: 4px; transition: width .4s ease; opacity: 0.9; }
.rp-bar-cp { font-size: 11px; color: var(--text-muted); margin-top: 5px; }
.rp-bd-total { display: flex; justify-content: space-between; font-weight: 700; font-size: 13.5px; padding-top: 12px; margin-top: 6px; border-top: 2px solid var(--border); }

.rp-top-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border-light); gap: 10px; }
.rp-top-row:last-child { border-bottom: none; }
.rp-top-main { display: flex; align-items: center; gap: 8px; min-width: 0; }
.rp-top-cp { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-top-meta { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.rp-top-date { font-size: 11px; color: var(--text-subtle); }
.rp-top-meta .num { font-size: 13.5px; font-weight: 600; }

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

/* ─── 조회 전용(viewer) 배너 ─────────────────────────────────── */
#viewer-banner { display: none; }
body[data-role="viewer"] #viewer-banner {
  display: block;
  background: #fffbeb; color: #92400e;
  font-size: 12.5px; font-weight: 600; text-align: center;
  padding: 8px 28px; border-bottom: 1px solid #fde68a;
  position: sticky; top: 0; z-index: 20;
}

/* ─── 구글 시트 내보내기 결과 ───────────────────────────────── */
.sheets-result { margin-top: 8px; padding: 16px; border: 1.5px solid var(--income-color); background: var(--income-bg); border-radius: 12px; text-align: center; }
.sheets-result-head { font-weight: 800; color: #065f46; margin-bottom: 12px; font-size: 14px; }
.sheets-open-btn { display: inline-flex; font-size: 14px; font-weight: 700; padding: 11px 22px; box-shadow: 0 2px 8px rgba(99,102,241,0.35); }
.sheets-result-sub { font-size: 12px; color: var(--text-muted); margin-top: 12px; line-height: 1.5; }
.sheets-result-sub b { color: var(--text); }

/* ─── 계좌 관리 ─────────────────────────────────────────────── */
.acct-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.acct-card { padding: 16px 18px; }
.acct-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.acct-bank { font-weight: 700; font-size: 14px; }
.acct-actions { display: flex; gap: 6px; }
.acct-del { color: var(--expense-color); }
.acct-no { font-size: 16px; font-weight: 700; letter-spacing: 0.3px; margin-bottom: 10px; color: var(--text); }
.acct-row { display: flex; justify-content: space-between; font-size: 12.5px; padding: 3px 0; color: var(--text-muted); }
.acct-row b { color: var(--text); font-weight: 600; }
.acct-stat { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border-light); font-size: 12px; color: var(--text-muted); }
.acct-det-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; gap: 10px; }
.acct-det-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.acct-det-meta { font-size: 12px; color: var(--text-muted); }

/* ─── 복원 검증 모달 ────────────────────────────────────────── */
.rs-note { font-size: 12.5px; color: var(--text-muted); line-height: 1.6; margin-bottom: 12px; background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 10px 12px; }
.rs-note b { color: var(--text); }
.rs-stores { display: flex; flex-direction: column; gap: 6px; }
.rs-store { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: var(--surface-2); border-radius: 8px; font-size: 13px; }
.rs-store-name { font-weight: 600; }
.rs-ok { color: var(--income-color); }
.rs-bad { color: var(--expense-color); }

/* ─── 가져오기 미리보기 모달 ─────────────────────────────────── */
.imp-prev-note { font-size: 12.5px; color: var(--text-muted); line-height: 1.6; margin-bottom: 12px; }
.imp-prev-note b { color: var(--text); }
.imp-prev-banks { display: flex; flex-wrap: wrap; gap: 8px; }
.imp-prev-bank { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; font-size: 13px; }

/* ─── 반응형 (모바일/태블릿) ─────────────────────────────────── */
#mobile-menu-btn { display: none; }
#sidebar-backdrop { display: none; }

/* 태블릿: 4열 KPI → 2열 */
@media (max-width: 1024px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .three-col { grid-template-columns: 1fr 1fr; }
  .chart-row, .two-col, .rp-two-col { grid-template-columns: 1fr; }
}

/* 모바일: 사이드바 → 슬라이드 드로어 */
@media (max-width: 768px) {
  #sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 1000;
    transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: 4px 0 28px rgba(15,23,42,0.28);
  }
  #sidebar.open { transform: translateX(0); }

  #sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 999;
    background: rgba(15,23,42,0.48); opacity: 0; pointer-events: none;
    transition: opacity .25s ease;
  }
  #sidebar-backdrop.show { opacity: 1; pointer-events: auto; }

  #mobile-menu-btn {
    display: flex; align-items: center; justify-content: center;
    position: fixed; top: 9px; left: 10px; z-index: 1001;
    width: 38px; height: 38px;
    border: 1px solid var(--border); border-radius: 9px;
    background: #fff; color: var(--text); font-size: 18px;
    cursor: pointer; box-shadow: var(--shadow-sm);
  }
  #mobile-menu-btn:active { background: var(--surface-2); }
  /* 드로어 열렸을 때 로고가 햄버거에 가리지 않도록 */
  .sidebar-header { padding-left: 56px; }

  #app { display: block; height: 100vh; overflow: hidden; }
  #main-content { width: 100%; height: 100vh; }

  .page-header { padding: 12px 14px 12px 58px; flex-wrap: wrap; gap: 8px; }
  .page-header h1 { font-size: 16px; }
  .page-header-actions { flex-wrap: wrap; gap: 6px; }
  .page-body { padding: 16px 14px; }

  /* 그리드 단일/2열화 */
  .stat-grid, .stat-grid-3 { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
  .chart-row, .two-col, .three-col, .rp-two-col { grid-template-columns: 1fr; gap: 12px; }

  .card { padding: 16px; }
  .stat-card { padding: 13px 15px; }
  .card-value { font-size: 19px; }

  #dash-period-bar { flex-wrap: wrap; }
  .rp-month-select { flex: 1; min-width: 96px; }

  /* 로그인 카드: 작은 화면에서도 넘치지 않게 */
  #login-screen > div { width: min(340px, 90vw) !important; padding: 32px 24px !important; }
}

/* 좁은 폰: KPI 1열 */
@media (max-width: 430px) {
  .stat-grid, .stat-grid-3 { grid-template-columns: 1fr; }
  .card-value { font-size: 21px; }
}
