/* ===================================================
   📁 파일 위치: /영일전기철물2/admin/assets/css/pages/quotation_management.css
   ✅ v4.0 — 실무형 관리 UI
   디자인 원칙:
   - 흰 배경 위 얇은 선 / 여백으로 구분
   - 색은 목적이 있을 때만 (미수=red, 완료=green)
   - 입력·버튼은 같은 높이 한 줄로
   - 리스트가 주인공
=================================================== */

/* ══ 래퍼 ═══════════════════════════════════════════ */
.qm-wrap {
  padding: 20px 24px 40px;
  max-width: 1060px;
  margin: 0 auto;
  font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
  font-size: 13px;
  color: #0f172a;
  line-height: 1.45;
}

/* ══ 페이지 헤더 ════════════════════════════════════ */
.qm-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.qm-page-title {
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.3px;
}

/* ══ 통합 작업바 ════════════════════════════════════
   검색 + 날짜 + 건수 + 조회 + 신규 → 한 줄 */
.qm-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

/* 공통 입력 */
.qm-input {
  height: 32px;
  border: 1px solid #dde3ec;
  border-radius: 6px;
  padding: 0 10px;
  font-size: 12.5px;
  color: #0f172a;
  background: #f8fafc;
  outline: none;
  transition: border-color .12s, box-shadow .12s, background .12s;
}
.qm-input::placeholder { color: #94a3b8; }
.qm-input:focus {
  background: #fff;
  border-color: #818cf8;
  box-shadow: 0 0 0 2px rgba(129,140,248,.18);
}
.qm-input-search { flex: 1; min-width: 140px; }
.qm-input-date   { width: 116px; }
.qm-select       { padding: 0 6px; cursor: pointer; }

.qm-date-range {
  display: flex;
  align-items: center;
  gap: 4px;
}
.qm-date-sep { font-size: 11px; color: #b0bac8; }

/* 툴바 구분선 */
.qm-toolbar-div {
  width: 1px;
  height: 20px;
  background: #e2e8f0;
  flex-shrink: 0;
}

/* ══ 버튼 ═══════════════════════════════════════════ */
.qm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .1s, border-color .1s;
}
.qm-btn-primary {
  background: #3730a3;
  color: #fff;
  border-color: #3730a3;
}
.qm-btn-primary:hover { background: #312e81; }
/* 신규 견적 버튼 (페이지 헤더) */
.qm-page-head .qm-btn-primary {
  height: 34px;
  padding: 0 16px;
  font-size: 13px;
}
.qm-btn-ghost {
  background: transparent;
  color: #475569;
  border-color: #dde3ec;
}
.qm-btn-ghost:hover { background: #f1f5f9; }
.qm-btn-search {
  background: #f1f5f9;
  color: #334155;
  border-color: #dde3ec;
}
.qm-btn-search:hover { background: #e2e8f0; }

/* ══ 상태 칩 필터 ════════════════════════════════════ */
.qm-chips-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.qm-chip {
  padding: 3px 12px;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
  background: transparent;
  font-size: 11.5px;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  transition: all .1s;
}
.qm-chip:hover { border-color: #94a3b8; color: #1e293b; }
.qm-chip--active {
  background: #1e293b;
  border-color: #1e293b;
  color: #fff;
}
.qm-chip--danger { border-color: #fca5a5; color: #dc2626; }
.qm-chip--danger:hover { background: #fee2e2; }
.qm-chip--danger.qm-chip--active { background: #dc2626; border-color: #dc2626; color: #fff; }
.qm-chips-spacer { flex: 1; }
.qm-page-meta { font-size: 11px; color: #94a3b8; }

/* ══ 요약 수치 ═══════════════════════════════════════
   미수가 핵심 → 가장 크게
   나머지는 보조 */
.qm-summary {
  display: flex;
  align-items: stretch;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.qm-stat {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 10px 16px;
  flex: 1;
  border-right: 1px solid #f1f5f9;
  min-width: 0;
}
.qm-stat:last-child { border-right: 0; }

/* 미수 강조 (마지막 stat) */
.qm-stat:last-child .qm-stat-val { font-size: 17px; }

.qm-stat-label {
  font-size: 9.5px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 3px;
  white-space: nowrap;
}
.qm-stat-val {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.qm-stat-val.is-good  { color: #059669; }
.qm-stat-val.is-bad   { color: #dc2626; }
.qm-stat-val.is-neutral { color: #334155; }
/* stat-div는 border-right로 대체하므로 숨김 */
.qm-stat-div { display: none; }

/* ══ 테이블 ══════════════════════════════════════════ */
.qm-table-wrap {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.qm-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}

/* 컬럼 폭 */
.qm-table col.c-main     { width: 210px; }
.qm-table col.c-customer { width: 108px; }
.qm-table col.c-date     { width: 88px;  }
.qm-table col.c-total    { width: 108px; }
.qm-table col.c-paid     { width: 100px; }
.qm-table col.c-remain   { width: 100px; }

/* 헤더 */
.qm-table thead tr {
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}
.qm-table thead th {
  padding: 10px 12px;
  font-size: 10.5px;
  font-weight: 700;
  color: #64748b;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  letter-spacing: .05em;
  text-transform: uppercase;
  user-select: none;
}
.qm-table thead th.th-right  { text-align: right; }
.qm-table thead th.th-center { text-align: center; }
.th-sortable { cursor: pointer; }
.th-sortable:hover { color: #1e293b; background: #f1f5f9; }
.qt-sort-icon {
  margin-left: 2px;
  font-size: 9px;
  opacity: 0.4;
}

/* 바디 행 */
.qm-table tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background .08s;
}
.qm-table tbody tr:last-child { border-bottom: 0; }

.qt-row { cursor: pointer; }
.qt-row:hover {
  background: #f0f4ff;
}
.qt-row:hover td:first-child {
  box-shadow: inset 3px 0 0 #4f46e5;
}

.qm-table tbody td {
  padding: 11px 12px;
  vertical-align: middle;
  overflow: hidden;
}

/* 빈 상태 */
.qt-empty {
  padding: 36px !important;
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
}

/* 금액 셀 */
.td-money {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: #334155;
}

/* 미수만 빨강 */
.qt-money-bad  { color: #dc2626; font-weight: 700; }
.qt-money-ok   { /* 총액: 기본 */ }
.qt-money-good { /* 입금: 기본 */ }

/* 날짜 */
.qt-date-td {
  text-align: center;
  font-size: 11.5px;
  color: #64748b;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 고객 */
.qt-cust-td {
  font-size: 12px;
  color: #475569;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── 현장 셀 내부 ─────────────────────────────────── */
.qt-main-top {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.qt-main-title {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.qt-project-link {
  font-size: 13px;
  font-weight: 600;
  color: #2563eb;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.qt-project-link:hover { text-decoration: underline; }

/* hover 시만 노출 — 배지 & 버튼 */
.qt-main-alert {
  display: none;
  margin-top: 3px;
  padding: 1px 6px;
  border-radius: 4px;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 10.5px;
  font-weight: 600;
  border: 1px solid #fecaca;
}
.qt-row:hover .qt-main-alert { display: inline-flex; }

.qt-main-actions {
  display: none;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}
.qt-row:hover .qt-main-actions { display: flex; }

.qt-row-btn {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 4px;
  border: 1px solid #dde3ec;
  background: #fff;
  color: #475569;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .1s;
}
.qt-row-btn:hover  { background: #f1f5f9; }
.qt-row-btn.is-accent {
  border-color: #fbbf24;
  background: #fffbeb;
  color: #92400e;
}
.qt-row-btn.is-link {
  border-color: #a5b4fc;
  background: #eef2ff;
  color: #3730a3;
}

/* ── 상태 배지 ────────────────────────────────────── */
.qt-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.4;
}
.qt-chip-draft    { background:#fef9c3; color:#854d0e; border:1px solid #fde68a; }
.qt-chip-pending  { background:#dbeafe; color:#1e40af; border:1px solid #bfdbfe; }
.qt-chip-approved { background:#dcfce7; color:#166534; border:1px solid #86efac; }
.qt-chip-hold     { background:#f5f3ff; color:#5b21b6; border:1px solid #ddd6fe; }

/* ══ 페이저 ══════════════════════════════════════════ */
.qm-pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 14px 0 0;
}
.qm-page-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid #dde3ec;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  color: #475569;
  transition: background .1s;
}
.qm-page-btn:hover:not(:disabled) { background: #f1f5f9; }
.qm-page-btn:disabled { opacity: .3; cursor: default; }
.qm-pager-info {
  font-size: 12px;
  color: #94a3b8;
  min-width: 120px;
  text-align: center;
}

/* ══ 수금 모달 ═══════════════════════════════════════ */
.qt-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}
.qt-modal {
  width: min(600px,96vw);
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,.2);
}
.qt-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
}
.qt-modal-title { font-size: 14px; font-weight: 700; }
.qt-x { border:0; background:transparent; font-size:20px; cursor:pointer; color:#94a3b8; }
.qt-x:hover { color:#334155; }
.qt-modal-body  { padding: 16px; }
.qt-modal-foot {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #f1f5f9;
  background: #f8fafc;
}
.qt-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.qt-field label {
  display: block;
  font-size: 12px;
  color: #64748b;
  margin-bottom: 4px;
}
.qt-field input,
.qt-field select {
  width: 100%;
  height: 34px;
  border-radius: 6px;
  border: 1px solid #dde3ec;
  padding: 0 10px;
  font-size: 13px;
  outline: none;
}
.qt-field input:focus,
.qt-field select:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 2px rgba(129,140,248,.18);
}
.qt-msg {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  border: 1px solid #e2e8f0;
}
.qt-msg.ok  { border-color:#86efac; background:#f0fdf4; color:#166534; }
.qt-msg.bad { border-color:#fca5a5; background:#fef2f2; color:#991b1b; }
.qt-hint { margin-top:10px; font-size:12px; color:#94a3b8; }

.qt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}
.qt-btn-primary { background:#3730a3; border-color:#3730a3; color:#fff; }
.qt-btn-primary:hover { background:#312e81; }
.qt-btn-ghost   { background:#fff; border-color:#dde3ec; color:#334155; }
.qt-btn-ghost:hover { background:#f1f5f9; }
.qt-btn-danger  { background:#ef4444; border-color:#ef4444; color:#fff; }
.qt-btn-danger:hover { background:#dc2626; }

/* ══ 반응형 ══════════════════════════════════════════ */
@media (max-width: 900px) {
  .qm-wrap { padding: 12px 14px 28px; }
  .qm-toolbar { flex-direction: column; align-items: stretch; }
  .qm-input-search { min-width: unset; }
  .qm-toolbar-div { display: none; }
  .qm-summary { flex-wrap: wrap; }
  .qm-stat { min-width: 40%; }
  .qm-table col.c-customer,
  .qm-table thead th:nth-child(2),
  .qm-table tbody td:nth-child(2) { display: none; }
  .qt-grid { grid-template-columns: 1fr; }
}

@media print {
  .qm-toolbar, .qm-chips-row, .qm-pager,
  .qt-main-actions, #qt-open-create { display: none !important; }
}
