/* ── Reset & Base ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', -apple-system, sans-serif; font-size: 14px;
       background: #f0f2f5; color: #222; display: flex; flex-direction: column;
       min-height: 100vh; }

/* ── Hamburger (공통) ──────────────────────────– */
.hamburger { background: none; border: none; cursor: pointer; padding: 6px;
             display: flex; flex-direction: column; gap: 5px; }
.hamburger span { display: block; width: 22px; height: 2px; background: #fff;
                  border-radius: 2px; transition: all .2s; }


/* ── Navbar (가로 탭) ─────────────────────────── */
.layout { display: flex; flex-direction: column; flex: 1; }
.navbar { display: flex; align-items: center; gap: 32px; background: #1e293b;
          color: #cbd5e1; padding: 0 28px; height: 64px; flex-shrink: 0; z-index: 100; }
.navbar-logo { font-size: 18px; font-weight: 700; color: #fff; white-space: nowrap; }
.navbar-tabs { list-style: none; display: flex; gap: 0; flex: 1; }
.navbar-tabs li a { display: block; padding: 20px 20px; color: #94a3b8;
                    text-decoration: none; transition: all .15s; font-size: 14px;
                    border-bottom: 3px solid transparent; }
.navbar-tabs li a:hover { background: #334155; color: #fff; }
.navbar-tabs li a.active { color: #fff; border-bottom-color: #3b82f6; background: #334155; }

#hamburger-tabs { display: none; }

/* ── 모바일 Navbar ────────────────────────────── */
@media (max-width: 768px) {
  .navbar { padding: 0 16px; gap: 16px; height: 56px; }
  .navbar-logo { font-size: 16px; }
  #hamburger-tabs { display: flex; }
  .navbar-tabs { display: none; position: absolute; top: 56px; left: 0; right: 0;
                 flex-direction: column; gap: 0; background: #0f172a; z-index: 99; }
  .navbar-tabs.show { display: flex; }
  .navbar-tabs li a { padding: 14px 20px; border-bottom: none; border-left: 3px solid transparent; }
  .navbar-tabs li a.active { border-left-color: #3b82f6; }
}

/* ── Content ──────────────────────────────────── */
.content { flex: 1; padding: 28px 32px; overflow-y: auto; min-width: 0; background: #f8fafc; }
.page { display: block; }
.page.hidden { display: none; }

/* ── Page Header ──────────────────────────────── */
.page-header { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-header h1 { font-size: 28px; font-weight: 700; color: #1e293b; }
.month-nav { display: flex; align-items: center; gap: 8px; background: #fff;
             border-radius: 8px; padding: 6px 12px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.month-nav button { background: none; border: none; font-size: 20px; cursor: pointer;
                    color: #64748b; line-height: 1; padding: 0 6px; }
.month-nav button:hover { color: #3b82f6; }
#current-month-label, #tx-month-label { font-weight: 600; min-width: 88px; text-align: center; font-size: 15px; }

/* ── Budget Box ───────────────────────────────── */
.budget-box { background: #fff; border-radius: 14px; padding: 24px; margin-bottom: 20px;
             box-shadow: 0 1px 3px rgba(0,0,0,.08); border: 1px solid #e2e8f0; }
.budget-box-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.budget-box h2 { font-size: 16px; font-weight: 700; color: #1e293b; }
.budget-summary { font-size: 14px; color: #64748b; }
.budget-detail-table { font-size: 13px; }

/* ── Voucher Box ───────────────────────────────── */
.voucher-box { background: #fff; border-radius: 14px; padding: 24px; margin-bottom: 20px;
              box-shadow: 0 1px 3px rgba(0,0,0,.08); border: 1px solid #e2e8f0; }
.voucher-box-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.voucher-box h2 { font-size: 16px; font-weight: 700; color: #1e293b; }
.voucher-detail-table { font-size: 13px; }

/* ── Summary Cards ────────────────────────────── */
.summary-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 20px; }
.card { background: #fff; border-radius: 12px; padding: 20px 22px;
        box-shadow: 0 1px 3px rgba(0,0,0,.08); border: 1px solid #e2e8f0; }
.card.blue  { background: linear-gradient(135deg, #eff6ff 0%, #fff 100%); border-color: #bfdbfe; }
.card.red   { background: linear-gradient(135deg, #fef2f2 0%, #fff 100%); border-color: #fca5a5; }
.card.green { background: linear-gradient(135deg, #f0fdf4 0%, #fff 100%); border-color: #86efac; }
.card.gray  { background: #f8fafc; border-color: #e2e8f0; }
.card-label { font-size: 12px; color: #64748b; margin-bottom: 8px; letter-spacing: .04em; font-weight: 500; }
.card-value { font-size: 20px; font-weight: 700; word-break: keep-all; color: #1e293b; }

/* ── Charts ───────────────────────────────────── */
.chart-box { background: #fff; border-radius: 14px; padding: 24px;
             box-shadow: 0 1px 3px rgba(0,0,0,.08); border: 1px solid #e2e8f0; overflow: hidden; margin-bottom: 20px; }
.chart-box h3 { font-size: 15px; font-weight: 700; margin-bottom: 16px; color: #1e293b; }
.chart-box.full-width { width: 100%; }
canvas { max-width: 100%; height: auto !important; }

/* ── Fixed Items Row ──────────────────────────── */
.fixed-items-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 20px; }

/* ── Fixed Expense Box ────────────────────────── */
.fixed-expense-box, .fixed-savings-box { background: #fff; border-radius: 14px; padding: 24px;
                                         box-shadow: 0 1px 3px rgba(0,0,0,.08); border: 1px solid #e2e8f0; }
.fixed-expense-box h3, .fixed-savings-box h3 { font-size: 15px; font-weight: 700; margin-bottom: 16px; color: #1e293b; }
.fixed-item { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center;
              padding: 10px 0; border-bottom: 1px solid #f1f5f9; }
.fixed-item:last-child { border-bottom: none; }
.fixed-cat { font-size: 13px; color: #475569; font-weight: 500; }
.fixed-amt { font-size: 14px; font-weight: 600; color: #222; }
.fixed-total { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center;
               padding: 12px 0 0 0; margin-top: 8px; border-top: 2px solid #e2e8f0; font-weight: 700; }

/* ── Calendar Box ─────────────────────────────── */
.calendar-box { background: #fff; border-radius: 14px; padding: 24px;
                box-shadow: 0 1px 3px rgba(0,0,0,.08); border: 1px solid #e2e8f0; }
.calendar-box h3 { font-size: 15px; font-weight: 700; margin-bottom: 16px; color: #1e293b; }

/* ── Tables ───────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { background: #f8fafc; padding: 8px 10px; text-align: center;
                 font-weight: 600; color: #475569; border-bottom: 2px solid #e2e8f0; white-space: nowrap; }
.data-table th:first-child, .data-table th:nth-child(2), .data-table th:nth-child(3) { text-align: left; }
.data-table td { padding: 7px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; height: 32px; }
.data-table td.cat-cell { height: 32px; padding: 2px 10px; }
.data-table tr:hover td { background: #f8fafc; }
.data-table td.amount { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table td.cancelled { color: #94a3b8; text-decoration: line-through; }

/* 거래내역 테이블 가로 스크롤 래퍼 */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* 카테고리 배지 */
.cat-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px 3px 8px; border-radius: 20px; font-size: 12px; font-weight: 500;
  border: 1px solid #bfdbfe; background: #eff6ff; color: #1d4ed8;
  cursor: pointer; white-space: nowrap; transition: background .15s;
  user-select: none;
}
.cat-badge::after { content: ' ✎'; font-size: 10px; opacity: .6; }
.cat-badge:hover, .cat-badge:active { background: #dbeafe; border-color: #93c5fd; }

/* 카테고리 select (편집 중) */
.cat-select {
  border: 1.5px solid #3b82f6; border-radius: 6px;
  padding: 4px 6px; font-size: 13px; background: #eff6ff; color: #1d4ed8;
  min-width: 100px; outline: none;
}

/* 카테고리 규칙 저장 체크박스 */
.cat-rule-chk {
  width: 16px; height: 16px; margin-left: 4px; cursor: pointer;
  vertical-align: middle;
}

/* 메모 셀 */
.memo-cell { cursor: pointer; }
.memo-text { color: #94a3b8; font-size: 12px; }
.memo-text.has-memo { color: #374151; font-size: 13px; }
.memo-cell:hover .memo-text, .memo-cell:active .memo-text { text-decoration: underline dotted #94a3b8; }
.memo-input { border: 1.5px solid #86efac; border-radius: 6px;
              padding: 4px 8px; font-size: 13px; min-width: 120px; outline: none; }

/* 예산 진행바 */
.progress-bar { height: 6px; background: #e2e8f0; border-radius: 3px; margin-top: 4px; }
.progress-fill { height: 100%; border-radius: 3px; background: #3b82f6; transition: width .3s; }
.progress-fill.over { background: #ef4444; }

/* ── Filter Bar ───────────────────────────────── */
.filter-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.filter-bar select { padding: 7px 10px; border: 1px solid #e2e8f0; border-radius: 6px;
                     background: #fff; font-size: 13px; }
.filter-bar label { display: flex; align-items: center; gap: 4px; color: #64748b; font-size: 13px; }

/* ── TX Footer ────────────────────────────────── */
.tx-footer { display: flex; justify-content: space-between; padding: 10px 0;
             color: #64748b; font-size: 13px; }
#tx-total { font-weight: 600; color: #222; }

/* ── Import ───────────────────────────────────── */
.import-box { max-width: 600px; }
.drop-zone { border: 2px dashed #cbd5e1; border-radius: 12px; padding: 32px 20px;
             text-align: center; background: #f8fafc; transition: all .2s; }
.drop-zone.dragover { border-color: #3b82f6; background: #eff6ff; }
.drop-zone p { color: #64748b; margin-bottom: 12px; }
.drop-zone .hint { font-size: 12px; color: #94a3b8; margin-top: 8px; }
.owner-select { margin: 16px 0; color: #64748b; }
.owner-select select { margin-left: 8px; padding: 6px 10px; border-radius: 6px;
                       border: 1px solid #e2e8f0; font-size: 14px; }
#import-log { margin-top: 16px; }
.import-result { padding: 12px 16px; border-radius: 8px; margin-bottom: 8px; font-size: 13px; }
.import-result.success { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }
.import-result.error   { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }

/* ── Settings ─────────────────────────────────── */
.settings-tabs { display: flex; gap: 0; margin-bottom: 0; flex-wrap: wrap;
                 border-bottom: 2px solid #e2e8f0; background: #fff; }
.stab { padding: 14px 20px; border: none; border-bottom: 3px solid transparent; background: transparent;
        border-radius: 0; cursor: pointer; font-size: 14px; font-weight: 500; color: #64748b;
        transition: all .15s; }
.stab:hover { color: #475569; background: #f8fafc; }
.stab.active { color: #3b82f6; border-bottom-color: #3b82f6; background: transparent; }
.stab-content { background: #fff; border-radius: 0; padding: 24px; box-shadow: none; }
.stab-content h3 { font-size: 16px; font-weight: 700; margin-bottom: 16px; display: flex;
                   align-items: center; gap: 10px; flex-wrap: wrap; color: #1e293b; }
.stab-content.hidden { display: none; }

/* ── Buttons ──────────────────────────────────── */
.btn-primary { padding: 10px 20px; background: #3b82f6; color: #fff; border: none;
               border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 600; }
.btn-primary:hover { background: #2563eb; }
.btn-outline { padding: 8px 16px; background: #fff; color: #3b82f6; border: 1px solid #3b82f6;
               border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; }
.btn-outline:hover { background: #eff6ff; }
.btn-sm { padding: 5px 12px; background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0;
          border-radius: 5px; cursor: pointer; font-size: 12px; }
.btn-sm:hover { background: #e2e8f0; }
.btn-danger { padding: 5px 12px; background: #fef2f2; color: #dc2626; border: 1px solid #fca5a5;
              border-radius: 5px; cursor: pointer; font-size: 12px; }
.btn-danger:hover { background: #fee2e2; }

/* ── Calendar ─────────────────────────────────── */
#calendar { font-size: 11px; }
.cal-header { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
              text-align: center; font-weight: 600; color: #64748b; margin-bottom: 4px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-day { min-height: 46px; padding: 3px; border-radius: 4px; background: #f8fafc; }
.cal-day.today { background: #eff6ff; }
.cal-day.empty { background: none; }
.cal-date { font-weight: 600; color: #475569; }
.cal-amount { color: #ef4444; font-size: 10px; margin-top: 1px; }

/* ── Legend ───────────────────────────────────── */
.pie-chart-container { display: flex; gap: 30px; align-items: center; }
.pie-chart-container canvas { flex-shrink: 0; }
.legend { display: flex; flex-direction: column; gap: 10px; font-size: 13px; line-height: 1.4; }
.legend-item { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }

/* ── Card scan box ────────────────────────────── */
.card-scan-box { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }

/* ── Misc ─────────────────────────────────────── */
.hint { font-size: 12px; color: #94a3b8; margin-bottom: 8px; }
input[type="text"], input[type="number"] {
  padding: 6px 10px; border: 1px solid #e2e8f0; border-radius: 6px;
  font-size: 13px; width: 100%; }
input[type="text"]:focus, input[type="number"]:focus {
  outline: none; border-color: #93c5fd; box-shadow: 0 0 0 2px rgba(59,130,246,.15); }

/* ── 연말정산 ─────────────────────────────────────── */
.tax-person-tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tax-ptab { padding: 9px 22px; border: 1px solid #e2e8f0; background: #fff;
            border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 600;
            color: #64748b; transition: all .15s; }
.tax-ptab:hover { background: #f1f5f9; }
.tax-ptab.active { background: #3b82f6; color: #fff; border-color: #3b82f6; }

.tax-body { display: grid; grid-template-columns: 1fr; gap: 20px; align-items: start; }
.tax-body-responsive { display: grid; grid-template-columns: 1fr; gap: 20px; }

@media (min-width: 1024px) {
  .tax-body-responsive { grid-template-columns: 1fr 1fr; }
}

.tax-user-section { display: flex; flex-direction: column; gap: 16px; }

#tax-user-tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tax-user-tab { padding: 9px 22px; border: 1px solid #e2e8f0; background: #fff;
                border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 600;
                color: #64748b; transition: all .15s; }
.tax-user-tab:hover { background: #f1f5f9; }
.tax-user-tab.active { background: #3b82f6; color: #fff; border-color: #3b82f6; }

.tax-inputs-panel { display: flex; flex-direction: column; gap: 16px; }

.tax-section { background: #fff; border-radius: 12px; padding: 18px 20px;
               box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.tax-section h3 { font-size: 14px; font-weight: 600; color: #475569; margin-bottom: 14px; }

.tax-field { margin-bottom: 12px; }
.tax-field label { display: block; font-size: 13px; color: #374151; margin-bottom: 5px; font-weight: 500; }
.tax-input-row { display: flex; align-items: center; gap: 6px; }
.tax-input-row input { flex: 1; }
.unit { font-size: 13px; color: #64748b; white-space: nowrap; }

.check-label { display: flex !important; align-items: center; gap: 8px;
               cursor: pointer; font-size: 14px !important; }
.check-label input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

.tax-sme-rates { padding: 8px 0 4px 24px; display: flex; flex-direction: column; gap: 6px; }
.tax-sme-rates label { display: flex; align-items: center; gap: 6px;
                       font-size: 13px; color: #374151; cursor: pointer; }

.tax-spend-row { display: flex; align-items: center; gap: 10px; padding: 6px 0;
                 border-bottom: 1px solid #f1f5f9; }
.tax-spend-row:last-child { border-bottom: none; }
.spend-label { flex: 0 0 90px; font-size: 13px; color: #374151; font-weight: 500; }
.spend-auto { flex: 1; text-align: right; font-size: 13px; font-weight: 600; color: #374151; }
.tax-spend-row input[type="number"] { flex: 1; text-align: right; }

#tax-result { flex: 1; min-width: 300px; }
.tax-result-inner { background: #fff; border-radius: 12px; padding: 20px;
                    box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.tax-result-inner h3 { font-size: 14px; font-weight: 600; color: #475569; margin-bottom: 12px; }

.tax-calc-table { width: 100%; }
.tax-calc-table td { padding: 6px 10px; font-size: 13px; }
.tax-calc-table td:last-child { width: 160px; }
.tax-divider td { padding: 0; border-top: 1.5px solid #e2e8f0 !important; }

/* ════════════════════════════════════════════════
   반응형 — 태블릿 (≤900px)
   ════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .summary-cards { grid-template-columns: repeat(2, 1fr); }
}

/* ════════════════════════════════════════════════
   반응형 — 모바일 (≤640px)
   ════════════════════════════════════════════════ */
@media (max-width: 640px) {
  /* 레이아웃 */
  body { flex-direction: column; }
  .topbar { display: flex; }
  .layout { flex: 1; position: relative; }

  /* 사이드바: 기본 숨김, 슬라이드로 열기 */
  .sidebar { position: fixed; left: -220px; top: 0; bottom: 0; width: 200px;
             z-index: 300; transition: left .25s ease; }
  .sidebar.open { left: 0; }
  .logo { padding-top: 16px; }

  /* 콘텐츠 전체 너비 */
  .content { padding: 16px 14px; background: #f8fafc; }

  /* 페이지 헤더 */
  .page-header { gap: 10px; margin-bottom: 16px; }
  .page-header h1 { font-size: 20px; }

  /* 요약 카드 */
  .summary-cards { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
  .card { padding: 16px 14px; border-radius: 10px; }
  .card-label { font-size: 11px; }
  .card-value { font-size: 16px; }

  /* 대시보드 박스 */
  .budget-box, .chart-box, .fixed-expense-box, .calendar-box { padding: 16px; margin-bottom: 12px; }
  .budget-box h2, .chart-box h3, .fixed-expense-box h3, .calendar-box h3 { font-size: 14px; margin-bottom: 12px; }

  /* 차트 */
  .charts-row { gap: 10px; }
  .chart-box { padding: 12px; }

  /* 거래내역 테이블 — 가로 스크롤 */
  #tx-table { min-width: 620px; }
  .filter-bar { gap: 6px; }
  .filter-bar select { font-size: 12px; padding: 6px 8px; }

  /* 설정 탭 — 세로 스크롤 */
  .settings-tabs { gap: 6px; }
  .stab { font-size: 12px; padding: 7px 10px; }
  .stab-content { padding: 14px; }

  /* 드롭존 */
  .drop-zone { padding: 24px 14px; }

  /* 달력 폰트 */
  .cal-day { min-height: 38px; }
  .cal-amount { font-size: 9px; }

  /* 고정 항목 */
  .fixed-items-row { grid-template-columns: 1fr; }

  /* 연말정산 */
  .tax-inputs-panel { flex: 1 1 100%; }
  #tax-result { flex: 1 1 100%; }
}
