/* ===========================================================
   고객/재무관리 (finance) — 공통 스타일
   참고: 얼마예요 2.0 색 체계(입금=적, 매출=청) + asms 디자인 토큰
   =========================================================== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "맑은 고딕", "Malgun Gothic", Dotum, sans-serif;
  font-size: 13px; color: #26303b; background: #f2f4f8;
}
a { text-decoration: none; color: inherit; }

/* ---------- 레이아웃 ---------- */
.fin-app { display: flex; min-height: 100vh; }
#fin-sidebar {
  flex: 0 0 208px; background: #1e2939; color: #cbd5e1;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.fin-brand {
  padding: 16px 14px; font-weight: 700; color: #fff; font-size: 15px;
  border-bottom: 1px solid #33415580;
}
.fin-brand a { margin-right: 4px; }
.fin-demo-badge {
  font-size: 10px; background: #f59e0b; color: #1e2939; border-radius: 8px;
  padding: 1px 7px; vertical-align: 2px; font-weight: 700;
}
.fin-nav { display: flex; flex-direction: column; padding: 10px 8px; gap: 2px; flex: 1; overflow-y: auto; }
.fin-nav-group {
  font-size: 10.5px; color: #64748b; font-weight: 700; letter-spacing: 1px;
  padding: 10px 12px 3px; text-transform: uppercase;
}
.fin-nav a {
  display: flex; align-items: center; gap: 9px; padding: 10px 12px;
  border-radius: 7px; font-size: 13.5px; color: #cbd5e1;
}
.fin-nav a:hover { background: #33415566; color: #fff; }
.fin-nav a.active { background: #3b82f6; color: #fff; font-weight: 700; }
.fin-side-foot { padding: 12px; border-top: 1px solid #33415580; display: flex; flex-direction: column; gap: 8px; }
.fin-paid-toggle { font-size: 12px; display: flex; align-items: center; gap: 6px; color: #94a3b8; cursor: pointer; }

.fin-main { flex: 1; padding: 20px 24px 60px; min-width: 0; }
.fin-page-title { font-size: 19px; font-weight: 800; margin: 0 0 4px; color: #111827; }
.fin-page-sub { color: #6b7280; font-size: 12.5px; margin: 0 0 16px; }

/* ---------- 카드 / KPI ---------- */
.fin-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  padding: 16px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.fin-card h3 { margin: 0 0 12px; font-size: 14.5px; color: #111827; }
.fin-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.fin-kpi {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px 16px;
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.fin-kpi .k-label { font-size: 12px; color: #6b7280; margin-bottom: 6px; }
.fin-kpi .k-value { font-size: 21px; font-weight: 800; color: #111827; letter-spacing: -.5px; }
.fin-kpi .k-sub { font-size: 11.5px; color: #9ca3af; margin-top: 4px; }
.fin-kpi.accent-blue  { border-top: 3px solid #3b82f6; }
.fin-kpi.accent-red   { border-top: 3px solid #ef4444; }
.fin-kpi.accent-green { border-top: 3px solid #10b981; }
.fin-kpi.accent-amber { border-top: 3px solid #f59e0b; }

/* ---------- 표 (얼마예요 장부 느낌) ---------- */
.fin-table { width: 100%; border-collapse: collapse; background: #fff; font-size: 12.5px; }
.fin-table th {
  background: #eef1f6; border: 1px solid #d9dee7; padding: 7px 8px;
  font-weight: 700; color: #374151; white-space: nowrap;
}
.fin-table td { border: 1px solid #e5e9f0; padding: 6px 8px; vertical-align: middle; }
.fin-table tr:hover td { background: #f5f8ff; }
.fin-table td.num, .fin-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.fin-table td.ctr { text-align: center; }
.amt-in  { color: #dc2626; font-weight: 700; }   /* 입금 — 얼마예요 적색 */
.amt-out { color: #1d4ed8; font-weight: 700; }   /* 매출/출금 — 청색 */
.amt-bal-pos { color: #dc2626; }
.amt-bal-neg { color: #1d4ed8; }

/* 구분 뱃지 (입금/매출/매입/출금) */
.fin-badge {
  display: inline-block; min-width: 34px; text-align: center; padding: 2px 7px;
  border-radius: 3px; color: #fff; font-size: 11px; font-weight: 700;
}
.fin-badge.bg-in   { background: #dc2626; }  /* 입금 */
.fin-badge.bg-sale { background: #1d4ed8; }  /* 매출 */
.fin-badge.bg-buy  { background: #b91c1c; }  /* 매입 */
.fin-badge.bg-out  { background: #1e40af; }  /* 출금 */
.fin-badge.bg-gray { background: #6b7280; }
.fin-badge.bg-green{ background: #059669; }
.fin-badge.bg-amber{ background: #d97706; }

/* 상태 pill */
.fin-pill { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.fin-pill.ok    { background: #d1fae5; color: #065f46; }
.fin-pill.warn  { background: #fef3c7; color: #92400e; }
.fin-pill.danger{ background: #fee2e2; color: #991b1b; }
.fin-pill.info  { background: #dbeafe; color: #1e40af; }
.fin-pill.gray  { background: #f3f4f6; color: #4b5563; }

/* ---------- 버튼 / 입력 ---------- */
.fin-btn {
  display: inline-block; padding: 7px 14px; border: 1px solid #cbd5e1; border-radius: 7px;
  background: #fff; color: #26303b; font-size: 12.5px; cursor: pointer; font-family: inherit;
}
.fin-btn:hover { background: #f1f5f9; }
.fin-btn.primary { background: #1e2939; border-color: #1e2939; color: #fff; font-weight: 700; }
.fin-btn.primary:hover { background: #33415f; }
.fin-btn.blue { background: #2563eb; border-color: #2563eb; color: #fff; font-weight: 700; }
.fin-btn.danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.fin-btn.small { padding: 4px 9px; font-size: 11.5px; }
.fin-btn.lock::before { content: "🔒 "; }
.fin-btn:disabled { opacity: .5; cursor: not-allowed; }
.fin-input, .fin-select, .fin-textarea {
  padding: 7px 9px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 12.5px;
  font-family: inherit; background: #fff;
}
.fin-input:focus, .fin-select:focus, .fin-textarea:focus { outline: 2px solid #93c5fd; border-color: #3b82f6; }
.fin-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.fin-toolbar .sp { flex: 1; }

/* ---------- 모달 ---------- */
.fin-modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); display: none;
  align-items: center; justify-content: center; z-index: 1000; padding: 16px;
}
.fin-modal-backdrop.show { display: flex; }
.fin-modal {
  background: #fff; border-radius: 12px; padding: 20px; width: 640px; max-width: 96vw;
  max-height: 92vh; overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25);
}

/* ---------- 상단 거래처 탭바 (견적/명세표/세금계산서/입금/미수금 공통) ---------- */
.fin-cotabs {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  padding: 6px 8px; margin-bottom: 14px; box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.fin-cotabs a {
  padding: 7px 13px; border-radius: 7px; font-size: 12.5px; color: #4b5563; white-space: nowrap;
}
.fin-cotabs a:hover { background: #f1f5f9; }
.fin-cotabs a.active { background: #1e2939; color: #fff; font-weight: 700; }
.fin-cotabs .cochip {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px;
  background: #dbeafe; color: #1e40af; border-radius: 14px; padding: 4px 6px 4px 12px;
  font-size: 12px; white-space: nowrap;
}
.fin-cotabs .cochip.none { background: #f3f4f6; color: #9ca3af; padding-right: 12px; }
.fin-cotabs .cochip button {
  border: 0; background: #1e40af; color: #fff; width: 18px; height: 18px; border-radius: 50%;
  cursor: pointer; font-size: 10px; line-height: 1;
}
@media (max-width: 860px) { .fin-cotabs .cochip { margin-left: 0; } }

/* ---------- 탭 ---------- */
.fin-tabs { display: flex; gap: 4px; border-bottom: 2px solid #e5e7eb; margin-bottom: 14px; }
.fin-tabs button {
  border: 0; background: none; padding: 9px 16px; font-size: 13px; cursor: pointer;
  color: #6b7280; font-family: inherit; border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.fin-tabs button.active { color: #1d4ed8; font-weight: 800; border-bottom-color: #1d4ed8; }

/* ---------- 문서(견적서/명세표/계산서) 공통 A4 ---------- */
.doc-a4 {
  background: #fff; width: 794px; max-width: 100%; margin: 0 auto; padding: 34px 38px;
  border: 1px solid #d1d5db; box-shadow: 0 4px 18px rgba(0,0,0,.08);
}
.doc-a4 table { border-collapse: collapse; width: 100%; }

/* 세금계산서 클래식 (공급자=적색 / 공급받는자=청색) */
.taxdoc { font-family: "맑은 고딕", sans-serif; }
.taxdoc .t-red  { color: #c00000; border-color: #c00000 !important; }
.taxdoc .t-blue { color: #1d4ed8; border-color: #1d4ed8 !important; }
.taxdoc td, .taxdoc th { border: 1px solid #c00000; padding: 4px 6px; font-size: 11.5px; }
.taxdoc.recv td, .taxdoc.recv th { border-color: #1d4ed8; }

/* ---------- 인쇄 ---------- */
@media print {
  body.fin-printing * { visibility: hidden; }
  body.fin-printing .fin-print-target, body.fin-printing .fin-print-target * { visibility: visible; }
  body.fin-printing .fin-print-target {
    position: absolute; left: 0; top: 0; width: 100%; border: 0; box-shadow: none; margin: 0;
  }
  #fin-sidebar { display: none; }
}

/* ---------- 반응형 ---------- */
@media (max-width: 860px) {
  .fin-app { flex-direction: column; }
  #fin-sidebar { position: static; height: auto; flex-basis: auto; }
  .fin-nav { flex-direction: row; flex-wrap: wrap; }
  .fin-main { padding: 12px; }
}
