/* ---- Reset & Base ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #ffeeda 0, #f5f6fa 40%, #edf0f5 100%);
  color: #333;
}

/* ---- Layout ---- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 230px;
  background: #ffffffdd;
  backdrop-filter: blur(10px);
  border-right: 1px solid rgba(0, 0, 0, 0.04);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  display: flex;
  align-items: center;
  margin-bottom: 32px;
}

.logo-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #ffb84d;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #222;
  margin-right: 10px;
}

.logo-title {
  font-size: 17px;
  font-weight: 700;
  color: #2563eb;
}

.sidebar-nav {
  flex: 1;
}

.nav-title {
  font-size: 12px;
  color: #9ca3af;
  margin-bottom: 8px;
}

.sidebar-nav ul {
  list-style: none;
}

.nav-item {
  padding: 9px 14px;
  margin-bottom: 4px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  color: #4b5563;
  transition: all 0.15s ease-out;
}

.nav-item:hover {
  background: #eff6ff;
  color: #2563eb;
}

.nav-item.active {
  background: #e0edff;
  color: #2563eb;
  font-weight: 600;
}

/* ---- Main ---- */
.main {
  flex: 1;
  padding: 24px 32px;
  overflow-y: auto;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 13px;
  color: #6b7280;
}

/* ---- Cards ---- */
.card {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid #eef0f5;
  background: linear-gradient(to bottom, #fbfcff, #ffffff);
}

.card-header-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-subtext {
  font-size: 12px;
  color: #9ca3af;
}

.card-body {
  padding: 18px 20px 20px;
}

.card-actions {
  display: flex;
  gap: 8px;
}

/* ---- Buttons ---- */
.btn {
  border-radius: 999px;
  border: none;
  font-size: 13px;
  padding: 8px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
  transition: all 0.12s ease-out;
}

.btn.primary {
  background: #2563eb;
  color: #fff;
}

.btn.primary:hover {
  background: #1d4ed8;
}

.btn.secondary {
  background: #e5edff;
  color: #2563eb;
}

.btn.secondary:hover {
  background: #d3e0ff;
}

.btn.ghost {
  background: transparent;
  border: 1px dashed #d1d5db;
  color: #4b5563;
}

.btn.ghost:hover {
  background: #f9fafb;
}

.btn.danger {
  background: #e35b5b;
  color: #fff;
}

.btn.danger:hover {
  background: #d74242;
}

/* ---- Inputs ---- */
.input-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
}

.input-group label {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 4px;
}

.input-group input,
.input-group select {
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
  background: #f9fafb;
  transition: border-color 0.12s ease-out, background 0.12s ease-out;
}

.input-group input:focus,
.input-group select:focus {
  background: #fff;
  border-color: #2563eb;
}

/* Layout helpers */
.grid-5 {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 10px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 8px;
}

.checkbox-row {
  display: flex;
  gap: 24px;
  margin-top: 8px;
  font-size: 13px;
}

.checkbox-row label {
  color: #4b5563;
}

/* ---- Quote: existing ---- */
.quote-existing {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-top: 10px;
}

/* ---- Tables ---- */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
}

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

.table thead {
  background: #f3f4f6;
}

.table.gray-header thead {
  background: #e5e7eb;
}

.table th,
.table td {
  padding: 8px 8px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
}

.table th {
  font-weight: 600;
  color: #4b5563;
}

.table td input {
  width: 100%;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  padding: 4px 6px;
  font-size: 13px;
  background: #fff;
}

.table td input:focus {
  border-color: #2563eb;
  outline: none;
}

.col-icon {
  width: 36px;
}

.col-copy {
  width: 50px;
  text-align: center;
}

/* ---- Customers layout ---- */
.customers-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1.4fr);
  grid-template-rows: auto 280px;
  grid-template-areas:
    "search quotes"
    "search detail";
  gap: 16px;
}

.customers-search {
  grid-area: search;
}

.customers-quotes {
  grid-area: quotes;
}

.customers-quote-detail {
  grid-area: detail;
}

.customer-list {
  margin-top: 12px;
  max-height: 520px;
  overflow-y: auto;
}

.customer-card {
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  padding: 10px 10px;
  margin-bottom: 8px;
  background: #f9fafb;
  cursor: pointer;
  transition: all 0.12s ease-out;
}

.customer-card.selected {
  border-color: #2563eb;
  background: #e5edff;
}

.customer-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}

.customer-info {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 4px;
}

.customer-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: #9ca3af;
}

.customer-meta button {
  font-size: 11px;
  padding: 4px 8px;
}

/* ---- Quote summary ---- */
.quote-summary {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  margin-top: 16px;
  gap: 18px;
}

.quote-summary-right {
  width: 320px;
  min-width: 320px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: 13px;
}

.summary-row span:first-child {
  color: #6b7280;
}

.summary-row-big {
  margin-top: 8px;
  border-top: 1px dashed #e5e7eb;
  padding-top: 6px;
}

.big-amount {
  color: #2563eb;
  font-weight: 700;
  font-size: 18px;
}

/* ---- Search view ---- */
.search-bar {
  margin-bottom: 10px;
}

.search-input-wrapper {
  max-width: 360px;
  position: relative;
}

.search-input-wrapper input {
  width: 100%;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  padding: 8px 12px 8px 30px;
  font-size: 13px;
  background: #f9fafb;
}

.search-input-wrapper input:focus {
  outline: none;
  border-color: #2563eb;
  background: #fff;
}

.icon-search {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
}

/* ---- Quote document ---- */
.quote-document {
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  padding: 24px 24px 20px;
  background: #fdfdfd;
  font-size: 13px;
}

.quote-doc-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.quote-doc-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}

.quote-doc-company {
  border: 1px solid #d1d5db;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
  background: #ffffff;
}

.quote-doc-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 12px;
}

.quote-doc-table th,
.quote-doc-table td {
  border: 1px solid #d1d5db;
  padding: 6px 6px;
}

.quote-doc-table th {
  background: #f3f4f6;
}

.quote-doc-summary {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

.quote-doc-summary-table {
  border-collapse: collapse;
  font-size: 12px;
}

.quote-doc-summary-table td {
  border: 1px solid #d1d5db;
  padding: 4px 8px;
}

.quote-doc-footer {
  margin-top: 12px;
  font-size: 11px;
  color: #4b5563;
}

.quote-doc-footer-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  width: 420px;
  background: #e5e5e5;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.35);
}

.modal-header {
  background: #007acc;
  color: #fff;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
}

.modal-body {
  padding: 16px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 16px 14px;
}

/* ---- Misc ---- */
/* 상태 배지 스타일 */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.table-placeholder {
  min-height: 120px;
}

#qc-big-total {
  text-align: right;
  display: inline-block;
}

/* ---- Customer Search Dropdown ---- */
.customer-search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  margin-top: 4px;
}

.customer-search-item {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
  transition: background 0.12s ease-out;
}

.customer-search-item:last-child {
  border-bottom: none;
}

.customer-search-item:hover {
  background: #f9fafb;
}

.customer-search-item.selected {
  background: #e5edff;
}

.customer-search-item-name {
  font-weight: 600;
  font-size: 13px;
  color: #1f2937;
  margin-bottom: 2px;
}

.customer-search-item-info {
  font-size: 11px;
  color: #6b7280;
}

.customer-search-item-company {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 2px;
}

/* print mode: hide sidebar */
@media print {
  /* 배경 제거 */
  html, body {
    background: #fff !important;
    background-image: none !important;
  }
  /* 컬러 인쇄 보정 */
  .quote-sheet, .quote-document, .quote-table, .card,
  .transaction-sheet, .transaction-document {
    -webkit-print-color-adjust: exact !important;
            print-color-adjust: exact !important;
    color-adjust: exact !important;
  }
  .sidebar,
  .page-header,
  .search-bar,
  .card-header .card-actions {
    display: none !important;
  }
  .app-layout {
    background: #fff !important;
    background-image: none !important;
  }
  .main {
    padding: 0;
    background: #fff !important;
    background-image: none !important;
  }
  .view {
    display: none !important;
  }
  
  /* 견적서 인쇄 모드 */
  body.print-quote .view[data-view="quote-search"] {
    display: block !important;
    background: #fff !important;
    background-image: none !important;
  }
  body.print-quote .view[data-view="transaction-create"] {
    display: none !important;
  }
  
  /* 거래명세서 인쇄 모드 */
  body.print-transaction .view[data-view="transaction-create"] {
    display: block !important;
    background: #fff !important;
    background-image: none !important;
  }
  body.print-transaction .view[data-view="quote-search"] {
    display: none !important;
  }
  
  /* 견적서 정보 수정 카드 숨기기 (견적서 인쇄 시에만) */
  body.print-quote #quote-edit-card {
    display: none !important;
  }
  /* 견적서 인쇄 전용 스타일 */
  body.print-quote .quote-results-card,
  body.print-quote .quote-preview-card .card-header {
    display: none !important;
  }
  /* 카드 크롬/여백 제거, 문서만 출력 */
  body.print-quote .card,
  body.print-quote .quote-preview,
  body.print-quote .quote-document,
  body.print-quote .quote-sheet {
    box-shadow: none !important;
    border-radius: 0 !important;
    border: none !important;
    background: #fff !important;
  }
  body.print-quote .quote-preview-card .card-body {
    padding: 0 !important;
  }
  /* 인쇄 시 문서만 보이도록 */
  body.print-quote .quote-preview {
    padding: 0 !important;
  }
  body.print-quote .quote-document {
    padding: 0 !important;
  }
  /* 인쇄: 표 정렬/자간/레이아웃 보정 */
  body.print-quote .quote-table {
    table-layout: fixed !important;
    width: 100% !important;
    border-spacing: 0 !important;
    border-collapse: separate !important;
  }
  /* 색상 테마 (인쇄 전용) */
  body.print-quote .quote-sheet {
    border: 1px solid #cfe0ff !important;
    border-radius: 12px !important;
    padding: 12px !important;
    background: #ffffff !important;
  }
  body.print-quote .company-card {
    border: 1px solid #cfe0ff !important;
    background: #f7fbff !important;
  }
  body.print-quote .company-card .company-name {
    color: #0f172a !important;
  }
  body.print-quote .sheet-banner {
    background: #ecf4ff !important;
    border: 1px solid #d3e7ff !important;
    color: #0b3b8e !important;
  }
  body.print-quote .quote-table thead th,
  body.print-quote .quote-table td {
    line-height: 1.2 !important;
    letter-spacing: normal !important;
    vertical-align: middle !important;
    padding: 6px 12px !important;
  }
  body.print-quote .quote-table thead th {
    text-align: left !important;
    background: #eef5ff !important;
    color: #1f2a44 !important;
    border-bottom: 1px solid #d9e6ff !important;
  }
  body.print-quote .quote-table tbody tr:nth-child(odd) td {
    background: #fbfdff !important;
  }
  body.print-quote .quote-table tbody tr:nth-child(even) td {
    background: #ffffff !important;
  }
  body.print-quote .quote-table tbody td {
    border-bottom: 1px solid #eef2f7 !important;
  }
  /* 고정 폭 컬럼 지정 (번호/단위/수량/단가/금액) */
  body.print-quote .quote-table thead th:nth-child(1),
  body.print-quote .quote-table tbody td:nth-child(1) { width: 48px !important; }
  body.print-quote .quote-table thead th:nth-child(2),
  body.print-quote .quote-table tbody td:nth-child(2) { width: auto !important; min-width: 5px !important; }
  body.print-quote .quote-table thead th:nth-child(3),
  body.print-quote .quote-table tbody td:nth-child(3) { width: 120px !important; }
  body.print-quote .quote-table thead th:nth-child(4),
  body.print-quote .quote-table tbody td:nth-child(4) { width: 51px !important; text-align: center !important; }
  body.print-quote .quote-table thead th:nth-child(5),
  body.print-quote .quote-table tbody td:nth-child(5) { width: 80px !important; }
  body.print-quote .quote-table thead th:nth-child(6),
  body.print-quote .quote-table tbody td:nth-child(6) { width: 95px !important; }
  body.print-quote .quote-table thead th:nth-child(7),
  body.print-quote .quote-table tbody td:nth-child(7) { width: 115px !important; }
  /* 텍스트 줄바꿈 규칙: 품목/규격만 줄바꿈 허용, 나머지는 단일 라인 유지 */
  body.print-quote .quote-table tbody td:nth-child(2),
  body.print-quote .quote-table tbody td:nth-child(3) {
    white-space: normal !important;
    word-break: break-word !important;
  }
  body.print-quote .quote-table thead th:nth-child(2),
  body.print-quote .quote-table thead th:nth-child(3) {
    white-space: nowrap !important;
  }
  /* 숫자형 우측 정렬 및 개행 방지 */
  body.print-quote .quote-table tbody td:nth-child(5),
  body.print-quote .quote-table tbody td:nth-child(6),
  body.print-quote .quote-table tbody td:nth-child(7),
  body.print-quote .quote-table thead th:nth-child(5),
  body.print-quote .quote-table thead th:nth-child(6),
  body.print-quote .quote-table thead th:nth-child(7) {
    text-align: right !important;
    white-space: nowrap !important;
    font-variant-numeric: tabular-nums;
  }
  /* 합계 패널 하이라이트 */
  body.print-quote .notes-grid {
    border: 1px solid #d9e6ff !important;
    background: #f8fbff !important;
  }
  body.print-quote .construction-conditions-box {
    border: 1px solid #d9e6ff !important;
    background: #f8fbff !important;
    font-size: 12px !important;
    line-height: 1.6 !important;
    color: #111827 !important;
  }
  body.print-quote .construction-condition-line {
    margin-bottom: 4px !important;
  }
  body.print-quote .totals-summary .row {
    background: #f6faff !important;
    border: 1px solid #d9e6ff !important;
    color: #0f172a !important;
    padding: 6px 12px !important;
  }
  body.print-quote .totals-summary .row.dump-row {
    background: #fafbfc !important;
    color: #64748b !important;
    font-size: 12px !important;
  }
  body.print-quote .totals-summary .grand {
    background: #ecf4ff !important;
    color: #0b3b8e !important;
    font-weight: 800 !important;
  }
  /* 인쇄 화면에서 박스 폭 조정 */
  body.print-quote .totals-bottom-grid {
    grid-template-columns: 1fr 300px !important;
  }
  
  /* 용지 설정 */
  @page {
    size: A4 portrait;
    margin: 12mm;
  }
}

/* ===== Quote Preview (검색 > 미리보기) ===== */
.quote-preview {
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
}
.quote-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #eef2f7;
}
.quote-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: #0f172a;
}
.quote-header .quote-info {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 12px 20px;
  color: #64748b;
  font-size: 13px;
}
.quote-body {
  margin-top: 18px;
}
.quote-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #ffffff;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid #eef2f7;
}
.quote-table thead th {
  background: #f3f4f6;
  color: #374151;
  font-weight: 600;
  font-size: 13px;
  padding: 12px 14px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
}
.quote-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: #111827;
  font-size: 13px;
}
.quote-table td.num {
  text-align: right;
}
.quote-table tr:last-child td {
  border-bottom: none;
}
.quote-summary {
  display: flex;
  justify-content: flex-end;
  gap: 24px;
  margin-top: 16px;
  padding: 16px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #eef2f7;
}
.quote-summary > div {
  min-width: 160px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #334155;
  font-weight: 600;
}
.quote-footer {
  margin-top: 16px;
  border-top: 1px dashed #e5e7eb;
  padding-top: 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px 16px;
}
.quote-footer .footer-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #475569;
  font-size: 13px;
}

/* 검색 상단 바 */
.search-bar {
  margin: 8px 0 16px;
}
.search-input-wrapper {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.search-input-wrapper input {
  border: none;
  outline: none;
  width: 100%;
  font-size: 14px;
}
.icon-search {
  color: #64748b;
}

/* ===== Modern refinements ===== */
.quote-preview {
  border: 1px solid #e9eef5;
  background: linear-gradient(180deg, #ffffff 0%, #fcfcfd 100%);
}

.quote-header h1 {
  font-size: 24px;
  background: linear-gradient(90deg, #111827 0%, #334155 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.quote-header .quote-info {
  gap: 8px 24px;
  color: #475569;
}

.quote-table {
  border: 1px solid #e6ebf2;
}
.quote-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: linear-gradient(180deg, #f7f8fa 0%, #f1f5f9 100%);
}
.quote-table tbody tr:nth-child(odd) td {
  background: #fbfdff;
}
.quote-table tbody tr:hover td {
  background: #eef6ff;
}

.quote-summary {
  background: linear-gradient(180deg, #f8fbff 0%, #f4f8ff 100%);
  border-color: #e5edf9;
}
.quote-summary > div {
  color: #1f2937;
}
.quote-summary > div:nth-child(3) {
  font-size: 18px;
  color: #0f172a;
}

.quote-footer {
  border-top: 1px dashed #dbe3ef;
}
.quote-footer .footer-row span:first-child {
  color: #64748b;
}

/* Search bar polish */
.search-input-wrapper {
  border-color: #dde3ea;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
}
.search-input-wrapper input::placeholder {
  color: #94a3b8;
}

/* Subtle drag visual for row moving */
tr.dragging td {
  opacity: 0.7;
  background: #e0f2fe !important;
}

.company-card {
  border: 1px solid #e6ebf2;
  border-radius: 12px;
  padding: 14px 16px;
  background: linear-gradient(180deg,#fbfcff 0,#f8fafc 100%);
  width: 320px;
}
.company-card .company-name {
  font-weight: 700;
  color: #0f172a;
  font-size: 16px;
  margin-bottom: 8px;
}
.company-card .company-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 8px 16px;
  font-size: 12px;
  color: #475569;
}
.company-card .company-grid .full { grid-column: 1 / -1; }
.company-card .company-grid span { color: #64748b; margin-right: 6px; }
.company-card .company-grid strong { color: #111827; font-weight: 600; }

/* ===== Quote sheet layout (screenshot-like) ===== */
.quote-sheet {
  background: #ffffff;
  border: 1px solid #e9eef5;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  padding: 16px;
}
.sheet-top {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  align-items: start;
}
.sheet-title {
  font-size: 22px;
  font-weight: 800;
  color: #0f172a;
}
.sheet-date {
  margin-top: 8px;
  color: #64748b;
  font-size: 13px;
}
.sheet-recipient { margin-top: 8px; }
.sheet-recipient span { color:#64748b; font-size:12px; margin-right:6px; }
.sheet-recipient strong { color:#0f172a; }

.sheet-banner {
  margin-top: 12px;
  background: #ecf4ff;
  border: 1px solid #dce9ff;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  color: #0f172a;
  font-weight: 700;
}
.sheet-banner .project-name { font-size: 14px; }
.sheet-banner .banner-total { color: #0b3b8e; }

.quote-table.quote-table-xl thead th {
  background: #eaf2ff;
  color: #1f2a44;
}
.quote-table.quote-table-xl td, .quote-table.quote-table-xl th {
  font-size: 12px;
}

.totals-panel {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 시공비 조건 박스 - 상단 전체 너비 */
.construction-conditions-box {
  padding: 10px 12px;
  border: 1px solid #e9eef5;
  border-radius: 12px;
  background: #f9fbff;
  font-size: 12px;
  line-height: 1.6;
  color: #111827;
}

.construction-condition-line {
  margin-bottom: 4px;
}

.construction-condition-line:last-child {
  margin-bottom: 0;
}

/* 하단 그리드 - 납품일자 박스와 공급가액 박스 */
.totals-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 12px;
  align-items: start;
}

.notes-grid {
  padding: 10px 12px;
  border: 1px solid #e9eef5;
  border-radius: 12px;
  background: #f9fbff;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.notes-grid .note {
  display: flex;
  align-items: center;
  gap: 8px;
}
.notes-grid .note span { 
  color:#64748b; 
  font-size:12px; 
  min-width: 80px;
}
.notes-grid .note p { 
  color:#111827; 
  font-size:13px; 
  margin: 0;
  flex: 1;
}
.notes-grid .note.full { 
  grid-column: 1 / -1; 
}

/* 공급가액 박스 */
.totals-summary {
  display: flex;
  flex-direction: column;
}

.totals-summary .row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 12px;
  border: 1px solid #e6ebf2;
  background: #f8fbff;
  margin: 0;
}

.totals-summary .row + .row { 
  border-top: none; 
}

.totals-summary .row.dump-row {
  background: #fafbfc;
  color: #64748b;
  font-size: 12px;
}

.totals-summary .row.grand {
  background: #f2f7ff;
  font-weight: 800;
}

/* ===== Quote Search Layout ===== */
.quote-search-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
}
@media (max-width: 1024px) {
  .quote-search-layout {
    grid-template-columns: 1fr;
  }
}
.quote-results-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 70vh;
  overflow: auto;
}
.quote-result-item {
  border: 1px solid #e6ebf2;
  border-radius: 12px;
  padding: 10px 12px;
  background: #ffffff;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
}
.quote-result-item:hover {
  background: #f8fbff;
  border-color: #dbe3ef;
}
.quote-result-item.active {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.quote-result-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.quote-result-title {
  font-weight: 600;
  font-size: 14px;
  color: #0f172a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.quote-result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 6px;
  font-size: 12px;
  color: #475569;
}
.badge-soft {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  font-size: 11px;
  color: #334155;
}
.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #64748b;
}

/* ===== Monthly board (Kanban) ===== */
.monthly-board {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 6px; /* 스크롤바가 뜰 때 카드와 겹치지 않도록 여백 */
  scroll-snap-type: x proximity;
}

/* ===== Dashboard Progress Panel ===== */
.dash-progress-board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}

@media (max-width: 1400px) {
  .dash-progress-board {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 1024px) {
  .dash-progress-board {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .dash-progress-board {
    grid-template-columns: 1fr;
  }
}

/* ===== 주간 캘린더 ===== */
#week-calendar-container {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
}

.week-day-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  min-height: 200px;
  transition: all 0.15s ease-out;
}

.week-day-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.week-day-card.today {
  border-color: #2563eb;
  background: #f0f7ff;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.week-day-header {
  display: flex;
  flex-direction: column;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eef2f7;
}

.week-day-name {
  font-size: 12px;
  color: #6b7280;
  font-weight: 500;
  margin-bottom: 4px;
}

.week-day-number {
  font-size: 20px;
  font-weight: 700;
  color: #1f2937;
}

.week-day-card.today .week-day-number {
  color: #2563eb;
}

.week-day-memo {
  flex: 1;
  margin-top: 8px;
}

.week-day-memo textarea {
  width: 100%;
  min-height: 120px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
  font-family: inherit;
  resize: vertical;
  background: #f9fafb;
  transition: all 0.12s ease-out;
  outline: none;
}

.week-day-memo textarea:focus {
  background: #ffffff;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.week-day-memo textarea::placeholder {
  color: #9ca3af;
}

.week-calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 0 4px;
}

.week-calendar-title {
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
}

@media (max-width: 1024px) {
  #week-calendar-container {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 768px) {
  #week-calendar-container {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  #week-calendar-container {
    grid-template-columns: 1fr;
  }
}

/* 스크롤바 미세 폴리시 (옵션) */
.monthly-board::-webkit-scrollbar {
  height: 8px;
}
.monthly-board::-webkit-scrollbar-thumb {
  background: #cfd8e3;
  border-radius: 8px;
}
.monthly-board::-webkit-scrollbar-track {
  background: #eef2f7;
  border-radius: 8px;
}
.col-kanban {
  background: #ffffff;
  border: 1px solid #e6ebf2;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  min-height: 120px;
  min-width: 260px; /* 가로 스크롤 시 각 컬럼의 기본 폭 */
  scroll-snap-align: start;
}
.col-kanban header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid #eef2f7;
  background: linear-gradient(180deg, #fbfcff 0, #ffffff 100%);
}
.col-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 13px;
}
.col-title .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.col-count {
  font-size: 12px;
  color: #64748b;
}
.col-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kanban-card {
  border: 1px solid #e6ebf2;
  border-radius: 10px;
  padding: 10px;
  background: #ffffff;
  line-height: 1.4;
  font-size: 12px;
  cursor: grab;
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}
.kanban-card:active {
  cursor: grabbing;
}
.kanban-card.dragging {
  opacity: 0.5;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.kanban-card:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}
.kanban-card .title {
  font-weight: 600;
  color: #111827;
  margin-bottom: 6px;
}
.kanban-card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  color: #475569;
}
.kanban-card .badge-soft {
  padding: 2px 8px;
}
.col-body.drag-over {
  background: #f0f9ff;
  border: 2px dashed #3b82f6;
  border-radius: 8px;
}

/* Settings Page */
.settings-system-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid #e2e8f0;
  margin-bottom: 0;
  padding-bottom: 0;
}

.settings-tab-btn {
  padding: 12px 20px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: #64748b;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: -2px;
}

.settings-tab-btn:hover {
  color: #334155;
  background: #f8fafc;
}

.settings-tab-btn.active {
  color: #3b82f6;
  border-bottom-color: #3b82f6;
  font-weight: 600;
}

.settings-section {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 20px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.settings-section:hover {
  border-color: #cbd5e1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.settings-section-title {
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #e2e8f0;
}

.settings-section .input-group {
  margin-bottom: 12px;
}

.settings-section .input-group:last-child {
  margin-bottom: 0;
}

.settings-section .input-group input {
  width: 100%;
  max-width: 200px;
}

.settings-rates-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ===== 거래명세서 작성 ===== */
.transaction-layout {
  display: grid;
  grid-template-columns: 400px minmax(0, 1fr);
  gap: 16px;
}

.transaction-quote-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 70vh;
  overflow-y: auto;
  margin-top: 12px;
}

.transaction-quote-item {
  border: 1px solid #e6ebf2;
  border-radius: 12px;
  padding: 10px 12px;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.12s ease;
}

.transaction-quote-item:hover {
  background: #f8fbff;
  border-color: #dbe3ef;
}

.transaction-quote-item.active {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.transaction-quote-item-title {
  font-weight: 600;
  font-size: 14px;
  color: #0f172a;
  margin-bottom: 4px;
}

.transaction-quote-item-meta {
  font-size: 12px;
  color: #475569;
}

.transaction-preview {
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
}

.transaction-sheet {
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 0;
  padding: 20px;
  font-size: 13px;
  page-break-inside: avoid;
}

.transaction-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #d1d5db;
}

.transaction-sheet-title {
  font-size: 18px;
  font-weight: 700;
  color: #000;
}

.transaction-sheet-page {
  font-size: 12px;
  color: #666;
}

.transaction-sheet-date {
  font-size: 12px;
  color: #666;
  margin-top: 4px;
}

.transaction-supplier-recipient-wrapper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.transaction-supplier-info,
.transaction-recipient-info {
  padding: 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
}

.transaction-info-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 8px;
  color: #000;
}

.transaction-info-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}

.transaction-info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.transaction-info-label {
  color: #666;
  font-weight: 500;
  white-space: nowrap;
}

.transaction-info-value {
  color: #000;
  margin-right: 16px;
}

.transaction-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 12px;
}

.transaction-table th,
.transaction-table td {
  border: 1px solid #d1d5db;
  padding: 8px;
  text-align: left;
}

.transaction-table th {
  background: #f3f4f6;
  font-weight: 600;
  text-align: center;
  color: #000;
}

.transaction-table td {
  background: #fff;
}

.transaction-table th:nth-child(1) { width: 50px; } /* 순번 */
.transaction-table th:nth-child(2) { width: auto; } /* 품명/규격 */
.transaction-table th:nth-child(3) { width: 60px; } /* 단위 */
.transaction-table th:nth-child(4) { width: 80px; text-align: right; } /* 수량 */
.transaction-table th:nth-child(5) { width: 100px; text-align: right; } /* 단가 */
.transaction-table th:nth-child(6) { width: 110px; text-align: right; } /* 금액 */

.transaction-table td:nth-child(1),
.transaction-table td:nth-child(3) {
  text-align: center;
}

.transaction-table td:nth-child(4),
.transaction-table td:nth-child(5),
.transaction-table td:nth-child(6) {
  text-align: right;
}

.transaction-summary {
  margin-top: 16px;
  padding: 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
}

.transaction-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  font-size: 12px;
}

.transaction-summary-col-left,
.transaction-summary-col-right {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.transaction-summary-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  line-height: 1.2;
}

.transaction-summary-label {
  color: #666;
}

.transaction-summary-value {
  color: #000;
  font-weight: 600;
}

.transaction-summary-row.total {
  border-top: 1px solid #d1d5db;
  margin-top: 8px;
  padding-top: 8px;
}

.transaction-summary-row.total .transaction-summary-value {
  font-size: 14px;
  font-weight: 700;
}

.transaction-footer {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
  font-size: 11px;
  color: #666;
  text-align: center;
}

.transaction-duplicate {
  margin-bottom: 40px;
  page-break-after: always;
}

.transaction-duplicate:last-child {
  page-break-after: auto;
}

/* 인쇄 모드에서는 페이지 나눔 제거 */
@media print {
  .transaction-duplicate {
    page-break-after: auto !important;
  }
  
  .transaction-duplicate:last-child {
    page-break-after: auto !important;
  }
}

.transaction-duplicate-label {
  font-weight: 600;
  font-size: 13px;
  color: #000;
  margin-bottom: 12px;
  text-align: center;
}


/* 거래명세서 인쇄용 스타일 */
@media print {
  body.print-transaction .transaction-layout {
    grid-template-columns: 1fr !important;
    display: block !important;
  }
  
  /* 좌측 패널 전체 숨기기 (견적서 선택 + 품목 선택) */
  body.print-transaction .transaction-layout > div:first-child {
    display: none !important;
  }
  
  /* 좌측 견적서 선택 카드 숨기기 */
  body.print-transaction .transaction-layout > .card:first-child,
  body.print-transaction #transaction-items-selection {
    display: none !important;
  }
  
  /* 우측 미리보기 카드만 보이도록 */
  body.print-transaction .transaction-preview-card {
    grid-column: 1 / -1 !important;
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  
  body.print-transaction .transaction-preview-card .card-header,
  body.print-transaction .page-header {
    display: none !important;
  }
  
  /* 미리보기 카드의 body만 보이도록 */
  body.print-transaction .transaction-preview-card {
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
  }
  
  body.print-transaction .transaction-preview-card .card-body {
    padding: 0 !important;
  }
  
  body.print-transaction .transaction-preview {
    padding: 0 !important;
  }
  
  body.print-transaction .transaction-sheet {
    border: 1px solid #d1d5db !important;
    padding: 10px !important;
    page-break-inside: avoid !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    font-size: 11px !important;
    line-height: 1.2 !important;
  }
  
  body.print-transaction .transaction-sheet-header {
    margin-bottom: 8px !important;
    padding-bottom: 6px !important;
  }
  
  body.print-transaction .transaction-sheet-title {
    font-size: 16px !important;
    line-height: 1.2 !important;
  }
  
  body.print-transaction .transaction-sheet-date {
    font-size: 10px !important;
    margin-top: 2px !important;
    line-height: 1.2 !important;
  }
  
  body.print-transaction .transaction-sheet-page {
    font-size: 10px !important;
    line-height: 1.2 !important;
  }
  
  body.print-transaction .transaction-supplier-recipient-wrapper {
    gap: 8px !important;
    margin-bottom: 8px !important;
  }
  
  body.print-transaction .transaction-supplier-info,
  body.print-transaction .transaction-recipient-info {
    padding: 6px 8px !important;
  }
  
  body.print-transaction .transaction-info-title {
    font-size: 11px !important;
    margin-bottom: 4px !important;
    line-height: 1.2 !important;
  }
  
  body.print-transaction .transaction-info-grid {
    gap: 2px !important;
    font-size: 10px !important;
    line-height: 1.2 !important;
  }
  
  body.print-transaction .transaction-info-row {
    gap: 6px !important;
    line-height: 1.2 !important;
  }
  
  body.print-transaction .transaction-info-label,
  body.print-transaction .transaction-info-value {
    line-height: 1.2 !important;
    margin-right: 12px !important;
  }
  
  body.print-transaction .transaction-table {
    margin: 8px 0 !important;
    font-size: 10px !important;
  }
  
  body.print-transaction .transaction-table th,
  body.print-transaction .transaction-table td {
    padding: 3px 4px !important;
    line-height: 1.2 !important;
  }
  
  body.print-transaction .transaction-table th {
    font-size: 10px !important;
    font-weight: 600 !important;
  }
  
  body.print-transaction .transaction-table td {
    font-size: 10px !important;
  }
  
  body.print-transaction .transaction-summary {
    margin-top: 8px !important;
    padding: 6px 8px !important;
  }
  
  body.print-transaction .transaction-summary-grid {
    gap: 8px !important;
    font-size: 10px !important;
  }
  
  body.print-transaction .transaction-summary-col-left,
  body.print-transaction .transaction-summary-col-right {
    gap: 2px !important;
  }
  
  body.print-transaction .transaction-summary-row {
    padding: 2px 0 !important;
    line-height: 1.2 !important;
  }
  
  body.print-transaction .transaction-summary-label,
  body.print-transaction .transaction-summary-value {
    font-size: 10px !important;
    line-height: 1.2 !important;
  }
  
  body.print-transaction .transaction-summary-row.total {
    margin-top: 4px !important;
    padding-top: 4px !important;
  }
  
  body.print-transaction .transaction-summary-row.total .transaction-summary-value {
    font-size: 11px !important;
  }
  
  body.print-transaction .transaction-duplicate {
    margin-bottom: 15px !important;
    page-break-inside: avoid !important;
    page-break-after: auto !important;
  }
  
  body.print-transaction .transaction-duplicate:last-child {
    margin-bottom: 0 !important;
    page-break-after: auto !important;
  }
  
  /* 두 개의 거래명세서가 한 페이지에 들어가도록 */
  body.print-transaction .transaction-preview {
    display: flex !important;
    flex-direction: column !important;
    gap: 0 !important;
  }
  
  body.print-transaction .transaction-sheet {
    max-height: 50% !important;
    overflow: hidden !important;
  }
  
  body.print-transaction .transaction-duplicate-label {
    font-size: 11px !important;
    margin-bottom: 6px !important;
    line-height: 1.2 !important;
  }
}
