/* ===================================================================
   기본 설정 및 폰트 (Base & Fonts)
   =================================================================== */
@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;700&display=swap");

body {
  font-family: "Noto Sans KR", sans-serif;
  background-color: #f0f2f5;
  color: #333;
  margin: 0;
  padding: 20px;
  font-size: 14px;
}

/* ===================================================================
   레이아웃 (Layout)
   =================================================================== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  background-color: #ffffff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.main-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  grid-template-areas:
    "header header"
    "company company"
    "management creator"
    "history history"
    "contracts contracts"
    "templates templates";
  gap: 20px;
}

.user-info-area {
  grid-area: header;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 15px;
  margin-bottom: 10px;
}

#company-info-section {
  grid-area: company;
}
.management-column {
  grid-area: management;
}
.quote-creator-column {
  grid-area: creator;
}
.quote-history {
  grid-area: history;
}
.contract-history {
  grid-area: contracts;
}
#template-info-section {
  grid-area: templates;
}

.site-footer {
  width: 100%;
  padding: 20px 0;
  margin-top: 40px;
  text-align: center;
  background-color: #f8f9fa;
  border-top: 1px solid #e9ecef;
  font-size: 13px;
  color: #6c757d;
}
.footer-content a {
  color: #6c757d;
  text-decoration: none;
  margin: 0 10px;
}
.footer-content a:hover {
  text-decoration: underline;
}
.footer-divider {
  color: #ced4da;
}

/* ===================================================================
   공통 요소 (Common Elements)
   =================================================================== */
.card {
  background-color: #fff;
  border: 1px solid #dddfe2;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

h2,
h3,
h4,
h5 {
  margin-top: 0;
  padding-bottom: 5px;
  border-bottom: 1px solid #eee;
}
h5 {
  margin-top: 15px;
}

hr {
  border: none;
  border-top: 1px solid #eee;
  margin: 20px 0;
}

button {
  background-color: #1877f2;
  color: white;
  border: none;
  padding: 10px 15px;
  border-radius: 6px;
  font-size: 0.9em;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s;
  margin-top: 10px;
}
button:hover {
  background-color: #166fe5;
}
button:disabled {
  background-color: #9dbef5;
  cursor: not-allowed;
}

button.primary-btn {
  background-color: #28a745;
}
button.primary-btn:hover {
  background-color: #218838;
}

button.secondary-btn {
  background-color: #6c757d;
  font-size: 0.8em;
  padding: 5px 10px;
  margin: 0 2px;
}
button.secondary-btn:hover {
  background-color: #5a6268;
}

.delete-btn {
  background-color: #dc3545;
  color: white;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  font-size: 0.8em;
  border-radius: 4px;
  margin: 0;
}
.delete-btn:hover {
  background-color: #c82333;
}

input,
select,
textarea {
  box-sizing: border-box;
  width: 100%;
  padding: 8px;
  margin-bottom: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1em;
  font-family: "Noto Sans KR", sans-serif;
}
textarea {
  resize: vertical;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 15px;
}

.table-responsive-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 15px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 15px;
  font-size: 0.9em;
}

th,
td {
  border: 1px solid #ddd;
  padding: 8px;
  text-align: center;
  vertical-align: middle;
}
th {
  background-color: #f8f9fa;
}

/* ===================================================================
   헤더 및 배너 (Header & Banner)
   =================================================================== */
header {
  padding: 0;
  margin-bottom: 10px;
}
.header-banner {
  width: 100%;
  height: auto;
  display: block;
}
header h1 {
  text-align: center;
  color: #1c1e21;
  margin-bottom: 30px;
}

/* ===================================================================
   섹션별 스타일: 회사, 고객, 품목 관리 (Management Sections)
   =================================================================== */
.collapsible-header {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  border-bottom: none;
}
.collapsible-header:hover {
  color: #1877f2;
}
.collapsible-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}
.collapsible-section.open .collapsible-content {
  padding-top: 15px;
}
.form-text-muted {
  font-size: 0.8em;
  color: #6c757d;
  margin-left: 5px;
}

.company-list-item {
  padding: 10px;
  border: 1px solid #eee;
  border-radius: 4px;
  margin-bottom: 5px;
  cursor: pointer;
  transition: background-color 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.company-list-item:hover {
  background-color: #f8f9fa;
}
.company-list-item.active {
  background-color: #e7f3ff;
  border-left: 4px solid #007bff;
  font-weight: bold;
}

.management-column .card {
  margin-bottom: 20px;
}
.management-column ul {
  list-style-type: none;
  padding: 0;
  max-height: 200px;
  overflow-y: auto;
  border-top: 1px solid #eee;
}
.management-column li {
  background-color: #f9f9f9;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
  padding: 10px 8px;
  position: relative;
}

.customer-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 8px;
  border-bottom: 1px solid #eee;
}
.customer-info {
  flex-grow: 1;
  margin-right: 10px;
}
.customer-name {
  font-weight: 500;
  font-size: 1.05em;
  word-break: break-all;
}
.customer-sub-info {
  font-size: 0.9em;
  color: #666;
  margin-top: 4px;
}
.customer-actions {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

.search-result-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}
.search-result-item:hover {
  background-color: #f8f9fa;
}
.search-result-item:last-child {
  border-bottom: none;
}
.search-result-name {
  font-weight: 500;
  color: #333;
}
.search-result-contact {
  font-size: 0.85em;
  color: #777;
}

.product-item-info {
  flex-grow: 1;
  margin-right: 10px;
}
.product-name {
  font-weight: 500;
  display: block;
}
.product-price {
  display: block;
  font-size: 0.9em;
  color: #333;
}
.product-memo {
  display: block;
  font-size: 0.85em;
  color: #777;
  margin-top: 2px;
}
.product-item-details {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.drag-handle-product {
  user-select: none;
  font-size: 1.2em;
  padding-right: 10px;
  color: #aaa;
  cursor: grab;
}
li.drag-over-top {
  border-top: 2px dashed #007bff;
}
li.drag-over-bottom {
  border-bottom: 2px dashed #007bff;
}

/* ===================================================================
   견적서 작성 (Quote Creator)
   =================================================================== */
.quote-creator h2 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  line-height: 1.4;
}
#current-company-name {
  color: #007bff;
  margin: 0 4px;
  font-weight: bold;
}

.quote-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
.quote-form-grid .full-width {
  grid-column: 1 / -1;
}

.layout-selector {
  display: flex;
  align-items: center;
  gap: 10px;
}
.layout-selector select {
  flex-grow: 1;
}
.layout-selector button {
  margin-top: -10px;
  flex-shrink: 0;
  width: 120px;
}

/* [신규] 견적서 품목 리스트 전체 컨테이너 */
#quote-item-list-container {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 4px;
  margin-bottom: 10px;
}

/* [신규] PC/모바일 공통 품목 입력부 스타일 */
.quote-item-entry {
  border-bottom: 1px solid #eee;
  padding: 10px;
}
.quote-item-entry:last-child {
  border-bottom: none;
}
.field-wrapper {
  display: flex;
  flex-direction: column;
}
.field-wrapper label {
  font-weight: 600;
  font-size: 0.8em;
  color: #555;
  margin-bottom: 3px;
  display: none; /* 기본적으로 숨김 (모바일에서만 표시) */
}
.field-wrapper input,
.field-wrapper select,
.field-wrapper textarea {
  width: 100%;
  padding: 8px;
  margin-bottom: 0;
  box-sizing: border-box;
}
.field-total {
  text-align: right;
  font-weight: bold;
  padding: 8px;
  align-items: center;
  justify-content: flex-end;
}

/* ===================================================================
   PC용 레이아웃 (769px 이상)
   =================================================================== */
@media (min-width: 769px) {
  /* style.css 파일에서 이 부분을 찾아 교체하세요 */

  /* [신규] 헤더 스타일 */
  .quote-item-header {
    display: grid;
    /* [수정] 할인액(1.5fr) 컬럼 추가, 총 7개 컬럼으로 변경 */
    grid-template-columns: 2.5fr 1.5fr 1fr 1.5fr 1.5fr 1.5fr 60px;
    gap: 10px;
    padding: 10px;
    background-color: #f8f9fa;
    font-weight: bold;
    font-size: 0.9em;
    border-bottom: 1px solid #ddd;
  }
  .quote-item-header > div {
    text-align: center;
  }

  /* [신규] 품목 입력부 Grid 레이아웃 */
  .quote-item-entry {
    display: grid;
    /* [수정] 헤더와 동일하게 7개 컬럼으로 변경 */
    grid-template-columns: 2.5fr 1.5fr 1fr 1.5fr 1.5fr 1.5fr 60px;
    grid-template-rows: auto auto; /* 2개의 행 */
    gap: 10px;
    align-items: center;
  }

  /* 각 필드를 Grid 영역에 배치 */
  .field-item {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
  }
  .field-spec {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
  }
  .field-quantity {
    grid-column: 3 / 4;
    grid-row: 1 / 2;
  }
  .field-price {
    grid-column: 4 / 5;
    grid-row: 1 / 2;
  }
  .field-discount {
    grid-column: 5 / 6;
    grid-row: 1 / 2;
  } /* [추가] 할인액 필드 위치 */
  .field-total {
    grid-column: 6 / 7;
    grid-row: 1 / 2;
  } /* [수정] 공급가액 위치 */
  .field-memo {
    grid-column: 1 / 7;
    grid-row: 2 / 3;
    display: flex;
    align-items: center;
    gap: 10px;
  } /* [수정] 메모가 차지하는 범위 */
  .field-delete {
    grid-column: 7 / 8;
    grid-row: 1 / 3;
  } /* [수정] 삭제 버튼 위치 */

  /* style.css */
  .field-memo-label {
    /* 이 부분은 아래 .field-memo 에서 함께 처리하므로 삭제하거나 주석처리합니다. */
    display: none;
  }
  .field-memo {
    /* [수정] 품목 아래부터 공급가액까지(1~5열) 넓게 차지하도록 변경합니다. */
    grid-column: 1 / 6;
    grid-row: 2 / 3;

    /* [추가] 라벨과 입력창을 가로로 배열하기 위해 flex를 적용합니다. */
    display: flex;
    align-items: center;
    gap: 10px;
  }
}

/* ===================================================================
   모바일용 레이아웃 (768px 이하)
   =================================================================== */
@media (max-width: 768px) {
  .quote-item-header {
    display: none; /* 모바일에선 헤더 숨김 */
  }
  .field-wrapper label {
    display: block; /* 모바일에서 숨겨진 라벨(자막)을 다시 표시합니다. */
  }
  .quote-item-entry {
    display: grid;
    /* [수정] 단가/할인액/공급가액을 한 줄에 표시하기 위해 3개 컬럼으로 변경 */
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
  }

  /* 모바일에서 각 필드 위치 지정 */
  .field-item {
    grid-column: 1 / 4;
  } /* 품목 */
  .field-spec {
    grid-column: 1 / 3;
  } /* 규격 */
  .field-quantity {
    grid-column: 3 / 4;
  } /* 수량 */
  .field-price {
    grid-column: 1 / 2;
  } /* 단가 */
  .field-discount {
    grid-column: 2 / 3;
  } /* 할인액 */
  .field-total {
    grid-column: 3 / 4;
    justify-content: space-between;
    border-top: none; /* 선 제거 */
    padding-top: 0;
    margin-top: 0;
  }
  .field-total::before {
    content: "공급가액";
    font-weight: bold;
  } /* 라벨 역할 */
  .field-memo {
    grid-column: 1 / 4;
  } /* 메모 입력란 */
  .field-delete {
    grid-column: 1 / 4;
  } /* 삭제 버튼 */

  .field-memo textarea {
    box-sizing: border-box;
  }

  .field-delete button {
    width: 100%;
  }
}

.total-section {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin: 20px 0;
  font-size: 1.1em;
}
.total-section p {
  margin: 5px 0;
  width: 100%;
  max-width: 350px;
  display: flex;
  justify-content: space-between;
}
.tax-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 350px;
  font-size: 0.9em;
  margin-bottom: 10px;
}
.tax-options label {
  margin-bottom: 0;
  white-space: nowrap;
}
.tax-options select {
  width: auto;
  flex-grow: 1;
  margin-left: 5px;
  margin-bottom: 0;
}
#tax-rate-container {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-left: 15px;
}
#tax-rate-container input {
  width: 70px;
  margin-bottom: 0;
}
/* [신규] '번호' 칸 내부 정렬을 위한 스타일 */
.number-cell-wrapper {
  display: flex;
  justify-content: space-between; /* 번호는 왼쪽, 버튼은 오른쪽으로 정렬 */
  align-items: center;
  width: 100%; /* 너비를 꽉 채움 */
}

/* [신규] '번호' 칸의 숫자 스타일 */
.number-cell-wrapper .value {
  font-weight: bold;
}

/* [수정] 기존 top-actions 버튼 스타일을 유지하되, 일부 미세 조정 */
.top-actions {
  display: flex;
  gap: 6px; /* 버튼 사이 간격 */
}

.top-actions button {
  margin: 0;
  padding: 4px 8px; /* 버튼 크기를 약간 작게 조절 */
  font-size: 0.75em; /* 글자 크기를 약간 작게 조절 */
}
/* 지난 견적서 목록 펼치기

/* ===================================================================
   견적서 목록 - PC용 (769px 이상)
   =================================================================== */
@media (min-width: 769px) {
  #quote-history-table {
    display: table;
    width: 100%;
    border-collapse: collapse;
  }
  #quote-history-table thead {
    display: table-header-group;
  }
  #quote-history-table tbody {
    display: table-row-group;
  }
  #quote-history-table tr {
    display: table-row;
  }
  #quote-history-table th,
  #quote-history-table td {
    display: table-cell;
    border-bottom: 1px solid #ddd;
    padding: 12px 8px;
    text-align: center;
    vertical-align: middle;
  }
  #quote-history-table th {
    border-top: 2px solid #333;
    border-bottom-width: 2px;
    background-color: #f8f9fa;
  }
  #quote-history-table .actions-cell {
    min-width: 380px;
  }
}

/* ===================================================================
   견적서 목록 - 모바일용 (768px 이하)
   =================================================================== */
@media (max-width: 768px) {
  #quote-history-table {
    border-collapse: separate;
    border-spacing: 0 10px; /* 행 사이에 간격 */
  }

  #quote-history-table thead {
    display: none; /* PC용 a-table 헤더 숨김 */
  }

  #quote-history-table tbody,
  #quote-history-table tr.quote-row {
    display: block;
    width: 100%;
  }

  #quote-history-table tr.quote-row {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    box-sizing: border-box;
    cursor: pointer;
  }

  /* 1. [해결] 접혀있을 때 (날짜, 업체명, 가격이 한 줄에 표시되도록 수정) */
  #quote-history-table tr.is-collapsed {
    display: flex;
    flex-wrap: nowrap; /* 줄바꿈 방지 */
    justify-content: space-between;
    align-items: center;
    gap: 15px;
  }

  #quote-history-table tr.is-collapsed td {
    display: none; /* 모든 셀 기본 숨김 */
  }

  #quote-history-table tr.is-collapsed td[data-label="고객명"],
  #quote-history-table tr.is-collapsed td[data-label="작성일"],
  #quote-history-table tr.is-collapsed td[data-label="총액"] {
    display: block; /* 필요한 셀만 다시 표시 */
    border: none;
    padding: 0;
    flex-shrink: 0;
    white-space: nowrap;
  }

  #quote-history-table tr.is-collapsed td[data-label="고객명"] {
    flex-grow: 1; /* 고객명은 남은 공간 모두 차지 */
    text-align: left;
  }

  #quote-history-table tr.is-collapsed td[data-label="고객명"] .value {
    font-weight: bold;
    font-size: 1.1em;
  }

  #quote-history-table tr.is-collapsed td[data-label="총액"] .value {
    color: #1877f2;
    font-weight: 500;
    font-size: 1.1em;
  }

  #quote-history-table tr.is-collapsed td[data-label="작성일"] .value {
    color: #666;
    font-size: 0.9em;
  }

  #quote-history-table tr.is-collapsed td::before {
    display: none;
  }

  /* 펼쳐진 상태 스타일 */
  #quote-history-table tr:not(.is-collapsed) td {
    display: flex;
    /* justify-content: space-between; <-- 이 속성을 제거했습니다 */
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
  }

  #quote-history-table tr:not(.is-collapsed) td:last-child {
    border-bottom: none;
  }

  #quote-history-table tr:not(.is-collapsed) td::before {
    content: attr(data-label);
    font-weight: bold;
    width: 75px;
    margin-right: 10px;
    flex-shrink: 0;
  }

  /* 2. [해결] 길쭉하게 나오던 '수정', '삭제' 버튼 문제 수정 */
  .quote-number-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }

  .top-actions {
    display: flex;
    gap: 6px; /* 버튼 사이 간격 */
  }

  .top-actions button {
    margin: 0;
  }

  /* 3. [해결] 하단 작업 버튼 잘림 문제 수정 */
  #quote-history-table td.actions-cell {
    flex-direction: column;
    align-items: stretch;
    padding-top: 15px; /* 위쪽 여백 추가 */
  }

  #quote-history-table td.actions-cell button {
    margin: 0;
    padding: 12px 5px; /* 버튼의 세로 길이를 늘려 누르기 쉽게 */
    font-size: 0.9em;
    font-weight: 500; /* 글자를 약간 굵게 */
    border-radius: 6px; /* 버튼 모서리를 부드럽게 */
    min-height: 40px; /* 버튼 최소 높이를 지정해 정렬을 맞춤 */
    box-sizing: border-box; /* 패딩이 크기에 포함되도록 */
  }

  /* '계약서 생성' 버튼을 더 강조 */
  .actions-grid .primary-btn {
    background-color: #28a745; /* 초록색 */
    font-weight: bold;
  }
}

/* ===================================================================
   지난 견적서 및 계약 관리 목록 (History Tables)
   =================================================================== */

#quote-pagination,
#customer-pagination,
#contract-pagination {
  text-align: center;
  margin-top: 20px;
}
.pagination-btn {
  margin: 0 4px;
}
.pagination-btn.active {
  background-color: #1877f2;
  color: white;
  cursor: default;
}
.status-read {
  color: #28a745;
  font-weight: bold;
}
.status-sent {
  color: #007bff;
  font-weight: bold;
}

/* ===================================================================
   계약서 양식 관리 (Template Section)
   =================================================================== */
#contract-template-form {
  background-color: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 25px;
  margin-top: 15px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
#contract-template-form #template-form-title {
  text-align: center;
  margin-bottom: 25px;
  font-size: 1.5em;
  color: #343a40;
  border-bottom: none;
}
#contract-template-form label {
  font-weight: 600;
  color: #495057;
  margin-bottom: 8px;
  display: block;
}
.checkbox-wrapper {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
}
.checkbox-wrapper input[type="checkbox"] {
  width: auto;
  margin: 0 10px 0 0;
}
.template-variable-buttons {
  margin-bottom: 15px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.template-variable-btn {
  background-color: #6c757d;
  color: white;
  border: 1px solid #5a6268;
  border-radius: 15px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  margin: 0;
}
.template-variable-btn:hover {
  background-color: #5a6268;
  border-color: #495057;
  transform: translateY(-2px);
}
.note-editor.note-frame {
  border-radius: 6px;
  border: 1px solid #ced4da;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.075);
}
.note-toolbar {
  background-color: #f8f9fa;
  border-bottom: 1px solid #ddd;
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
}
.note-editable {
  font-family: "Malgun Gothic", Apple SD Gothic Neo, sans-serif;
  font-size: 14px;
}

/* ===================================================================
   모달 (Modals)
   =================================================================== */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.6);
}
.modal-content {
  background-color: #fefefe;
  margin: 5% auto;
  padding: 20px;
  border: 1px solid #888;
  width: 90%;
  max-width: 800px;
  border-radius: 8px;
  position: relative;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}
.close-btn {
  color: #aaa;
  position: absolute;
  top: 10px;
  right: 20px;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  z-index: 100; /* 다른 요소들과 겹치지 않도록 값을 크게 높입니다. */
}
.close-btn:hover,
.close-btn:focus {
  color: black;
  text-decoration: none;
}

#customer-modal .modal-content,
#product-modal .modal-content,
#calculator-modal .modal-content {
  max-width: 500px;
}

.modal form input {
  width: calc(100% - 22px);
  padding: 10px;
  margin-bottom: 15px;
}
.modal form button {
  width: 100%;
}

/* 미리보기 모달 (견적서/계약서 공통) */
.modal-content.wide {
  max-width: 900px;
  width: 75%;
  margin: 2% auto;
}
#quote-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #eee;
  padding-bottom: 15px;
  margin-bottom: 20px;
}
#quote-preview-header h3 {
  margin: 0;
  font-size: 1.2em;
}
#quote-preview-body {
  width: 100%;
  height: 70vh;
  overflow: auto;
  background-color: #f0f2f5;
  padding: 20px;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
#quote-preview-body .document-container {
  transform-origin: top center;
  margin: 0 auto;
}
#quote-preview-footer {
  position: static;
  width: 100%;
  padding: 15px 0 0 0;
  box-shadow: none;
  background: none;
  margin-top: 15px;
  border-top: 1px solid #eee;
}
.bottom-action-bar {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}
.bottom-action-bar button {
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.9em;
  font-weight: 500;
  margin: 0;
}
.bottom-action-bar .btn-primary {
  background-color: #1877f2;
  color: white;
}
.bottom-action-bar .btn-secondary {
  background-color: #6c757d;
  color: white;
}
.bottom-action-bar .btn-kakao {
  background-color: #fee500;
  color: #191919;
}

/* [수정] 레이아웃 테마 선택 미리보기 모달 */
#layout-preview-modal {
  /* display: none; /* JS에서 제어 */
  background-color: rgba(0, 0, 0, 0.85); /* 배경 더 어둡게 */
  align-items: center;
  justify-content: center;
}

#layout-preview-modal .modal-content-full {
  /* 새 클래스 이름 */
  background-color: #f0f2f5;
  width: 90vw;
  max-width: 1000px;
  height: 90vh;
  max-height: 800px;
  border-radius: 8px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#layout-preview-modal .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid #ddd;
  background-color: #fff;
  flex-shrink: 0;
}

#layout-preview-modal .modal-header h2 {
  margin: 0;
  font-size: 1.3em;
  color: #333;
  border-bottom: none;
}

#layout-preview-modal .modal-body {
  flex-grow: 1;
  position: relative;
  overflow: hidden;
}

#layout-preview-modal .close-button {
  font-size: 2.2em;
  color: #888;
  font-weight: 300;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
}
#layout-preview-modal .close-button:hover {
  color: #000;
}

/* [신규] 슬라이더 관련 스타일 */
#layout-slider-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  cursor: grab;
  user-select: none;
}

#layout-slider {
  display: flex;
  height: 100%;
  transition: transform 0.3s ease-in-out;
}

.layout-preview-page {
  flex: 0 0 100%;
  height: 100%;
  box-sizing: border-box;
  padding: 20px;
  overflow-y: auto;
  text-align: center;
  position: relative; /* 유료 오버레이 기준 */
}

.layout-preview-page h3 {
  margin-top: 0;
  color: #444;
  margin-bottom: 20px;
  font-weight: 500;
}

.layout-preview-page .document-container {
  transform: scale(0.8);
  transform-origin: top center;
  width: 125%; /* 100% / 0.8 */
  margin-left: -12.5%; /* (125% - 100%) / 2 */
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  background: white;
}

/* 유료 레이아웃 오버레이 */
.layout-preview-page.disabled {
  background: #e9ecef;
  position: relative; /* 오버레이의 기준점 */
  pointer-events: none; /* 페이지 전체 클릭 방지 (오버레이는 다시 활성화) */
}

/* 유료 레이아웃의 실제 미리보기 내용만 흐리게 처리 */
.layout-preview-page.disabled .document-container,
.layout-preview-page.disabled h3 {
  /* 제목도 흐리게 */
  filter: blur(3px) grayscale(50%);
  transition: filter 0.3s ease; /* 부드러운 전환 효과 */
}

/* 오버레이 스타일 */
.layout-preview-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.75); /* 배경 투명도 살짝 높임 */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  z-index: 10; /* 가장 위에 보이도록 */
  pointer-events: all; /* 오버레이 자체는 클릭 가능하도록 */
  /* 오버레이 자체에는 필터를 적용하지 않습니다 */
  filter: none;
}

/* 오버레이 내의 요소들은 필터 영향을 받지 않도록 */
.layout-preview-overlay * {
  filter: none;
}

.layout-preview-overlay .premium-badge {
  position: absolute;
  top: 30px;
  background-color: #ffc107;
  color: #212529;
  padding: 6px 12px;
  border-radius: 15px;
  font-size: 0.9em;
  font-weight: bold;
}
.layout-preview-overlay h3 {
  font-size: 1.5em;
  margin-bottom: 10px; /* 제목과 텍스트 사이 간격 */
  color: #333; /* 제목 색상 조정 */
}
.layout-preview-overlay .overlay-text {
  font-size: 1.1em;
  color: #444; /* 텍스트 색상 조정 */
  line-height: 1.6;
  margin-bottom: 25px; /* 텍스트와 버튼 사이 간격 */
}
.layout-preview-overlay .premium-badge {
  position: absolute;
  top: 30px;
  background-color: #ffc107;
  color: #212529;
  padding: 6px 12px;
  border-radius: 15px;
  font-size: 0.9em;
  font-weight: bold;
}
.layout-preview-overlay h3 {
  font-size: 1.5em;
}
.layout-preview-overlay .overlay-text {
  font-size: 1.1em;
  color: #333;
  line-height: 1.6;
}

/* 슬라이더 제어 버튼 */
.slider-button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background-color: rgba(0, 0, 0, 0.4);
  color: white;
  border: none;
  width: 40px;
  height: 60px;
  cursor: pointer;
  font-size: 1.8em;
  z-index: 10;
  border-radius: 5px;
  user-select: none;
  transition: background-color 0.2s ease;
}
.slider-button:hover:not(:disabled) {
  background-color: rgba(0, 0, 0, 0.7);
}
.slider-button:disabled {
  background-color: rgba(0, 0, 0, 0.15);
  cursor: not-allowed;
}
#layout-prev-btn {
  left: 15px;
}
#layout-next-btn {
  right: 15px;
}

/* 모바일 반응형에서 버튼 크기 조정 */
@media (max-width: 768px) {
  #layout-preview-modal .modal-content-full {
    width: 100vw;
    height: 100vh;
    max-height: none;
    border-radius: 0;
  }
  .layout-preview-page .document-container {
    transform: scale(0.6);
    width: 166.67%;
    margin-left: -33.33%;
  }
  .slider-button {
    width: 35px;
    height: 50px;
    font-size: 1.5em;
  }
  #layout-prev-btn {
    left: 5px;
  }
  #layout-next-btn {
    right: 5px;
  }
}
#quote-item-table .td-spec,
#quote-item-table .td-quantity {
  min-width: unset; /* 데스크톱에서 설정한 최소 너비 해제 */
  width: 100%; /* 모바일 그리드 칸에 꽉 차도록 설정 */
}
/* [추가] 견적서 테이블 래퍼의 가로 스크롤을 강제로 제거합니다. */
.table-responsive-wrapper {
  overflow-x: hidden;
}

/* [추가] 데스크톱에서 설정된 최소 너비 값을 모바일에서 제거하여 스크롤 발생을 원천적으로 방지합니다. */
#quote-item-table .td-product-name,
#quote-item-table .td-memo {
  min-width: unset;
}
/* 세금 계산기 모달 */
.calc-tabs {
  display: flex;
  border-bottom: 1px solid #ccc;
  margin-bottom: 15px;
}
.calc-tabs .tab-btn {
  padding: 10px 15px;
  border: none;
  background-color: transparent;
  cursor: pointer;
  margin-top: 0;
  border-radius: 6px 6px 0 0;
  color: #555;
  font-weight: 500;
}
.calc-tabs .tab-btn.active {
  background-color: #fff;
  border: 1px solid #ccc;
  border-bottom: 1px solid #fff;
  font-weight: bold;
  color: #000;
}
.calc-content {
  display: none;
}
.calc-content.active {
  display: block;
}
.calc-grid {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 10px;
  align-items: center;
}
.calc-grid label {
  font-weight: 500;
}
.calc-grid input {
  margin: 0;
  text-align: right;
}
.calc-grid input:read-only {
  background-color: #f0f0f0;
}
/* 데스크톱에서는 a-table의 thead를 사용하므로, 내부에 추가한 label을 숨깁니다. */
#quote-item-table label {
  display: none;
}
/* ===================================================================
   모바일 반응형 (Mobile Responsive)
   =================================================================== */
@media (max-width: 768px) {
  body {
    padding: 10px;
    font-size: 13px;
  }
  .container {
    padding: 15px;
  }
  header h1 {
    font-size: 1.5em;
  }

  .main-layout {
    display: flex;
    flex-direction: column;
  }
  .user-info-area {
    order: 1;
  }
  .quote-creator-column {
    order: 2;
  }
  .quote-history {
    order: 3;
  }
  .contract-history {
    order: 4;
  }
  .management-column {
    order: 5;
  }
  #company-info-section {
    order: 6;
  }
  #template-info-section {
    order: 7;
  }

  .user-info-area {
    flex-direction: column;
    align-items: center;
    gap: 10px !important;
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
  }
  .user-info-area button,
  .user-info-area a {
    width: 100%;
    max-width: 320px;
  }
  .user-info-area a {
    text-align: center;
    display: block;
    padding: 8px 15px;
    border-radius: 5px;
    background-color: #28a745;
    color: white !important;
    text-decoration: none;
    font-size: 0.9em;
  }

  .quote-form-grid {
    grid-template-columns: 1fr;
  }
  .tax-options {
    /* [수정] 세로 정렬을 가로 정렬로 변경 */
    flex-direction: row;
    align-items: center; /* 세로 중앙 정렬 */
    gap: 10px;
    width: 100%;
    max-width: 100%;
    flex-wrap: wrap; /* [추가] 공간이 부족하면 자동으로 줄바꿈 처리 */
  }
  .tax-options select {
    /* [수정] 남은 공간을 모두 차지하도록 설정 */
    flex-grow: 1;
    width: auto; /* 고정 너비 해제 */
  }
  #tax-rate-container {
    /* [수정] 필요한 만큼의 너비만 차지하도록 설정 */
    flex-shrink: 0;
    width: auto; /* 고정 너비 해제 */
  }

  #quote-history-table,
  #contract-history-table {
    overflow-x: hidden;
  }
  #quote-history-table thead,
  #contract-history-table thead {
    display: none;
  }

  #quote-history-table,
  #quote-history-table tbody,
  #quote-history-table tr,
  #contract-history-table,
  #contract-history-table tbody,
  #contract-history-table tr {
    display: block;
    width: 100%;
  }
  #quote-history-table tr,
  #contract-history-table tr {
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    box-sizing: border-box;
  }
  #quote-history-table td,
  #contract-history-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
  }
  #quote-history-table td:last-child,
  #contract-history-table td:last-child {
    border-bottom: none;
    padding-bottom: 0;
  }
  #quote-history-table td::before,
  #contract-history-table td::before {
    content: attr(data-label);
    font-weight: bold;
    text-align: left;
    flex-shrink: 0;
    margin-right: 10px;
  }
  #quote-history-table td .value,
  #contract-history-table td .value {
    text-align: center;
    flex-grow: 1;
    word-break: break-all;
  }

  .quote-number-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }
  .top-actions {
    display: flex;
    gap: 6px;
  }
  .top-actions button {
    margin: 0;
  }
  #quote-history-table td.actions-cell {
    display: block;
    padding: 15px 0 0 0; /* 좌우 여백 제거, 위쪽 여백만 설정 */
    border-top: 1px solid #eee;
    margin-top: 10px;
  }
  #quote-history-table td.actions-cell::before {
    margin-bottom: 10px;
  }

  .action-row {
    display: flex;
    gap: 8px;
    width: 100%;
  }

  .action-row + .action-row {
    margin-top: 8px;
  }

  .action-row button {
    flex: 1; /* 행 안에서 공간을 균등하게 차지 */
    min-width: 0; /* flex item의 최소 너비 제한 해제 (중요!) */
    margin: 0;
    padding: 10px 5px;
    font-size: 0.9em;
    border-radius: 6px;
    border: none;
  }

  #contract-history-table td.actions-cell {
    flex-direction: column;
    padding-top: 15px;
    margin-top: 5px;
    align-items: stretch;
    gap: 8px;
  }
  #contract-history-table td.actions-cell::before {
    margin-bottom: 10px;
    width: 100%;
  }
  #contract-history-table td.actions-cell button {
    width: 100%;
    margin: 0;
    text-align: center;
    padding: 10px;
    box-sizing: border-box;
    font-size: 0.9em;
  }

  /* 모달 */
  .modal-content {
    margin: 10% auto;
    width: 95%;
  }
  .modal-content.wide {
    margin: 5% auto;
    width: 90%;
    max-width: 98%;
  }
  #quote-preview-body {
    padding: 10px;
    height: 60vh;
  }
  .bottom-action-bar button {
    flex-grow: 1;
  }
  .calc-tabs {
    flex-direction: column;
    gap: 8px;
  }
  .calc-tabs button {
    width: 100%;
    padding: 10px;
  }
}
/* ===================================================================
   게임 모달 스타일 (추가)
   =================================================================== */
.game-tabs {
  display: flex;
  flex-wrap: wrap; /* 모바일에서 탭이 줄바꿈 되도록 */
  gap: 5px;
}
.game-tabs .tab-btn {
  padding: 8px 12px;
  border: 1px solid transparent;
  background-color: #f0f0f0;
  color: #555;
  cursor: pointer;
  margin-top: 0;
  border-radius: 6px 6px 0 0;
  font-weight: 500;
  font-size: 0.9em;
}
.game-tabs .tab-btn.active {
  background-color: #fff;
  border-color: #ccc #ccc #fff;
  color: #000;
}
.game-tab-content {
  display: none;
}
.game-tab-content.active {
  display: block;
}
#games-modal iframe {
  width: 100%;
  height: 550px; /* 게임 화면 높이 */
  border: none;
  border-radius: 4px;
  background-color: #eee;
}

@media (max-width: 768px) {
  #games-modal iframe {
    height: 60vh; /* 모바일에서는 화면 높이에 비례하게 조정 */
  }
  /* [추가] 계약 목록 모바일 접기/펼치기 스타일 */
  #contract-history-table tr.contract-row.is-collapsed {
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
  }

  /* 접혔을 때 모든 셀(td)을 일단 숨김 */
  #contract-history-table tr.contract-row.is-collapsed td {
    display: none;
  }

  /* 접혔을 때 보여줄 셀(고객명, 생성일, 상태)만 다시 표시 */
  #contract-history-table tr.contract-row.is-collapsed td[data-label="고객명"],
  #contract-history-table tr.contract-row.is-collapsed td[data-label="생성일"],
  #contract-history-table tr.contract-row.is-collapsed td[data-label="상태"] {
    display: block;
    border: none;
    padding: 0;
  }

  /* 고객명은 길어질 수 있으므로 남은 공간을 모두 차지하도록 설정 */
  #contract-history-table tr.contract-row.is-collapsed td[data-label="고객명"] {
    flex-grow: 1;
    text-align: left;
    font-weight: bold;
  }

  /* 접혔을 때는 '고객명:' 같은 라벨 텍스트 숨김 */
  #contract-history-table tr.contract-row.is-collapsed td::before {
    display: none;
  }
}
/* ===================================================================
   게임 설명 스타일 (추가)
   =================================================================== */
.game-description {
  background-color: #f8f9fa;
  border-left: 4px solid #007bff;
  padding: 12px 15px;
  margin-top: 0;
  margin-bottom: 15px;
  font-size: 0.9em;
  color: #495057;
  border-radius: 0 4px 4px 0;
}

.game-description strong {
  color: #0056b3;
}
/* ===================================================================
   모바일 게임 모달 전체 화면 처리 (추가)
   =================================================================== */
@media (max-width: 768px) {
  #games-modal .modal-content.wide {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
    border-radius: 0;
    display: flex;
    flex-direction: column;

    /* ▼▼▼ 이 부분을 수정 및 추가하세요 ▼▼▼ */
    padding: 15px; /* 기존 여백을 조금 줄입니다. */
    box-sizing: border-box; /* padding이 너비에 포함되도록 하여 화면을 넘어가지 않게 합니다. */
    /* ▲▲▲ 여기까지 수정 및 추가 ▲▲▲ */
  }

  #games-modal .game-tab-content {
    /* flex 아이템이 남은 공간을 모두 차지하도록 설정 */
    flex-grow: 1;
    display: flex; /* 내부 iframe의 크기 조정을 위해 추가 */
    flex-direction: column;
  }

  #games-modal iframe {
    flex-grow: 1; /* iframe이 부모 요소의 남은 공간을 모두 차지 */
    height: 100%; /* 높이를 100%로 설정 */
  }
}
/* style.css 파일에 추가 */
.layout-preview-page {
  position: relative; /* 자식 요소의 absolute 포지셔닝을 위한 기준점 */
}

.layout-select-overlay {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 10;
}

.select-layout-btn {
  padding: 8px 16px;
  font-size: 0.9em;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* 주요 정보 행과 메모 행을 시각적으로 묶기 위해 아래쪽 테두리 제거 */
#quote-item-table .item-row td {
  border-bottom: none;
}

/* 메모 행의 모든 셀(td)에 대한 공통 스타일 */
#quote-item-table .memo-row td {
  border-top: 1px dashed #e0e0e0;
  background-color: #fdfdfd;
  vertical-align: middle;
}

/* 메모 입력란이 있는 셀 */
#quote-item-table .memo-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  width: 100%; /* [추가] 이 한 줄을 추가하여 가로 너비를 최대로 확장합니다. */
}

#quote-item-table .memo-cell label {
  flex-shrink: 0;
  font-weight: 600;
  font-size: 0.9em;
  color: #555;
  margin-bottom: 0;
}

/* [수정] input을 textarea로 변경하고, 세로 크기 조절 옵션을 추가합니다. */
#quote-item-table .memo-cell textarea.quote-item-memo {
  flex-grow: 1;
  margin-bottom: 0;
  resize: vertical; /* 사용자가 세로로만 크기를 조절할 수 있게 함 */
  min-height: 38px; /* 기본 높이를 다른 input과 비슷하게 맞춤 */
}

/* [수정] 삭제 버튼이 있는 셀을 오른쪽으로 정렬합니다. */
#quote-item-table .memo-actions-cell {
  text-align: right; /* 버튼을 오른쪽 끝으로 보냄 */
  padding-right: 10px; /* 오른쪽에 약간의 여백 추가 */
}
.item-main-info {
  font-weight: 500; /* 품목명을 약간 굵게 표시 */
}

.item-spec {
  color: #555;
  font-size: 0.95em;
  margin-left: 4px;
}

.item-memo {
  color: #666;
  font-size: 0.9em;
  margin-top: 4px; /* <br> 태그를 대체 */
}
/* ===================================================================
   [PC 복구] 견적서 목록 작업 버튼 (769px 이상)
   =================================================================== */
@media (min-width: 769px) {
  /* 작업 칸의 최소 너비를 확보하여 버튼이 한 줄에 표시되도록 합니다. */
  #quote-history-table .actions-cell {
    min-width: 420px;
    white-space: nowrap; /* 버튼 줄바꿈 방지 */
  }

  /* 모바일에서 사용한 행(row) 구조를 PC에서는 무시합니다. */
  #quote-history-table .action-row {
    display: inline;
  }

  /* PC용 버튼 스타일을 원래의 작고 심플한 디자인으로 되돌립니다. */
  #quote-history-table .actions-cell button {
    display: inline-block; /* 버튼을 가로로 배열 */
    width: auto; /* 너비는 내용에 맞게 자동 조절 */
    flex: none; /* flex 관련 속성 초기화 */
    padding: 5px 8px; /* 작은 여백 */
    margin: 0 2px; /* 버튼 사이 간격 */
    font-size: 0.85em; /* 작은 폰트 크기 */
  }

  /* PC에서는 모든 버튼 색상을 원래대로 되돌립니다. */
  #quote-history-table .actions-cell .btn-kakao,
  #quote-history-table .actions-cell button[data-action="jpg"] {
    background-color: #6c757d; /* 기본 회색(secondary) 버튼 색상 */
    color: white;
  }

  #quote-history-table .actions-cell .primary-btn {
    background-color: #28a745; /* 기본 초록색(primary) 버튼 색상 */
  }
  /* [추가] PC용 계약 목록 버튼 스타일 */
  #contract-history-table .actions-cell {
    white-space: nowrap;
  }

  #contract-history-table .actions-cell button {
    display: inline-block;
    width: auto;
    flex: none;
    padding: 5px 8px;
    margin: 0 2px;
    font-size: 0.85em;
  }
}
/* ===================================================================
   [추가] 견적서 작성란 접기/펼치기 스타일
   =================================================================== */

/* 펼침/접힘 화살표 회전 효과 */
.collapsible-arrow {
  transition: transform 0.3s ease;
  display: none; /* PC에서는 기본적으로 숨김 */
}
.collapsible-section.open .collapsible-arrow {
  transform: rotate(180deg);
}

/* PC 화면 (769px 이상) 에서는 항상 펼쳐진 상태로 고정 */
@media (min-width: 769px) {
  .quote-creator.collapsible-section .collapsible-content {
    max-height: none !important;
    overflow: visible;
    padding-top: 0;
  }
  .quote-creator.collapsible-section .collapsible-header {
    cursor: default; /* 클릭 커서 제거 */
  }
}

/* 모바일 화면 (768px 이하) 에서만 접기/펼치기 기능 활성화 */
@media (max-width: 768px) {
  .quote-creator.collapsible-section .collapsible-header {
    cursor: pointer;
  }
  .quote-creator.collapsible-section .collapsible-arrow {
    display: inline-block; /* 모바일에서 화살표 보이기 */
  }
  .quote-creator.collapsible-section:not(.open) .collapsible-content {
    max-height: 0;
    overflow: hidden;
    padding-top: 0;
    margin-top: -10px; /* 접혔을 때 아래 요소와의 간격 조정 */
  }
}
/* ===================================================================
   [추가] 견적서 작성란 제목 스타일
   =================================================================== */
.quote-creator .collapsible-header {
  flex-direction: column; /* 제목과 화살표를 세로로 정렬 */
  text-align: center;
  padding-bottom: 10px;
}

.header-title-wrapper .main-title {
  display: block; /* 줄바꿈을 위해 block 요소로 변경 */
  font-size: 1.2em;
}

.header-title-wrapper .company-name-wrapper {
  display: block; /* 줄바꿈을 위해 block 요소로 변경 */
  font-size: 0.9em;
  font-weight: normal;
  color: #555;
  margin-top: 4px;
}

.collapsible-prompt {
  display: none; /* 기본적으로 숨김 */
  text-align: center;
  font-size: 0.85em;
  color: #888;
  margin-top: -5px;
  margin-bottom: 15px;
}

.quote-creator .collapsible-header .collapsible-arrow {
  margin-top: 8px; /* 제목과 화살표 사이 간격 */
}

/* PC에서는 기존 스타일과 비슷하게 복원 */
@media (min-width: 769px) {
  .quote-creator .collapsible-header {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }
  .header-title-wrapper .main-title,
  .header-title-wrapper .company-name-wrapper {
    display: inline; /* PC에서는 한 줄에 표시 */
  }
  .header-title-wrapper .company-name-wrapper {
    margin-top: 0;
  }
}

/* 모바일에서 섹션이 닫혀 있을 때만 안내 문구 표시 */
@media (max-width: 768px) {
  .quote-creator.collapsible-section:not(.open) .collapsible-prompt {
    display: block;
  }
}
/* ===================================================================
   [추가] 모바일 사용자 정보 한 줄 정렬
   =================================================================== */
.user-greeting-status {
  display: flex;
  flex-wrap: wrap; /* 화면이 매우 좁을 때 줄바꿈 허용 */
  justify-content: center; /* 내부 요소들을 중앙 정렬 */
  align-items: center;
  gap: 8px; /* 문구와 구독 상태 사이 간격 */
}
/* ===================================================================
   [추가] 흐르는 공지사항 바 스타일
   =================================================================== */
#notice-bar {
  width: 100%;
  background-color: lab(14.2% 0 0);
  color: #ffffff;
  padding: 8px 0;
  overflow: hidden;
  cursor: pointer;
  margin: 0 0 15px 0;
  border-radius: 4px;
}

.notice-content-wrapper {
  display: flex;
  white-space: nowrap;
  /* 래퍼의 너비를 내용에 맞게 설정하여 잘리지 않도록 합니다. */
  width: max-content;
  animation: marquee 10s linear infinite;
}

.notice-content-wrapper p {
  /* 두 개의 p 태그가 가로로 나열되도록 간격을 줍니다. */
  margin: 0;
  padding-right: 5em;
  font-size: 0.9em;
}

#notice-bar:hover .notice-content-wrapper {
  animation-play-state: paused;
}

@keyframes marquee {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}
/* ===================================================================
   [PC 수정] 공지사항 위치 및 스타일 변경 (769px 이상)
   =================================================================== */
@media (min-width: 769px) {
  /* 1. 메인 레이아웃의 grid-template-areas를 수정하여
        첫 번째 행에 공지사항('notice')과 헤더('header')를 나란히 배치합니다. */
  .main-layout {
    grid-template-areas:
      "notice header"
      "company company"
      "management creator"
      "history history"
      "contracts contracts"
      "templates templates";
  }

  /* 2. #notice-bar를 'notice' grid area에 할당하고 스타일을 변경합니다. */
  #notice-bar {
    grid-area: notice; /* 'notice' 영역에 배치 */
    background-color: #ffffff; /* 요청대로 흰색 배경으로 변경 */
    color: #333; /* 요청대로 검은색 계열 글씨로 변경 */
    border: 1px solid #e9ecef; /* 시각적 구분을 위한 옅은 테두리 추가 */
    margin: 0; /* 기존 마진 제거 */
    align-self: center; /* 헤더 영역과 세로 중앙 정렬 */
  }
}
/* 계약 관리 모달 - 서명 상태 표시 */
.signature-status-grid {
  display: flex;
  justify-content: space-around;
  gap: 20px;
  margin-bottom: 15px;
  text-align: center;
}
.status-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.party-label {
  font-weight: 500;
  color: #555;
  font-size: 0.95em;
}
.status-badge {
  padding: 5px 12px;
  border-radius: 15px;
  font-size: 0.9em;
  font-weight: bold;
  min-width: 80px;
}
.status-pending {
  background-color: #6c757d;
  color: white;
}
.status-completed {
  background-color: #28a745;
  color: white;
}
/* 계약서 모바일 양식

/* --- 모바일 단독 계약서 테이블 레이아웃 및 제목 수정 --- */
@media (max-width: 768px) {
  /* 1. 불필요한 PC용 테이블 헤더를 숨깁니다. */
  #standalone-contract-modal #sc-item-table thead {
    display: none;
  }

  /* 2. 테이블 행(tr)을 Grid 컨테이너로 만들어 셀(td)을 재배치합니다. */
  #standalone-contract-modal #sc-item-table tbody tr {
    display: grid;
    grid-template-columns: 3fr auto 2fr;
    grid-template-rows: auto auto;
    gap: 10px 15px; /* 세로, 가로 간격 */
    padding: 15px 0;
    border-bottom: 1px solid #eee;
  }
  #standalone-contract-modal #sc-item-table tbody tr:last-child {
    border-bottom: none;
  }

  /* 3. 각 셀(td)의 기본 스타일을 초기화하고 Grid 영역에 배치합니다. */
  #standalone-contract-modal #sc-item-table tbody td {
    padding: 0;
    border: none;
    display: block;
  }

  /* [추가] 헤더가 숨겨진 대신 각 입력칸 위에 제목(라벨)을 추가합니다. */
  #standalone-contract-modal #sc-item-table tbody td::before {
    display: block;
    font-weight: 600;
    font-size: 0.9em;
    color: #555;
    margin-bottom: 5px;
  }
  #standalone-contract-modal #sc-item-table td:nth-child(1)::before {
    content: "품목/서비스";
  }
  #standalone-contract-modal #sc-item-table td:nth-child(2)::before {
    content: "수량";
  }
  #standalone-contract-modal #sc-item-table td:nth-child(3)::before {
    content: "단가";
  }

  /* 1행 배치: 품목, 수량, 단가 */
  #standalone-contract-modal #sc-item-table td:nth-child(1) {
    grid-area: 1 / 1 / 2 / 2;
  }
  #standalone-contract-modal #sc-item-table td:nth-child(2) {
    grid-area: 1 / 2 / 2 / 3;
  }
  #standalone-contract-modal #sc-item-table td:nth-child(3) {
    grid-area: 1 / 3 / 2 / 4;
  }

  /* 2행 배치: 공급가액, 삭제 버튼 */
  #standalone-contract-modal #sc-item-table td:nth-child(4) {
    grid-area: 2 / 1 / 3 / 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: bold;
    padding: 5px;
    background-color: #f8f9fa;
    border-radius: 4px;
  }
  #standalone-contract-modal #sc-item-table td:nth-child(5) {
    grid-area: 2 / 3 / 3 / 4;
  }

  /* 수량 입력칸 너비 줄이기 */
  #standalone-contract-modal #sc-item-table .sc-item-quantity {
    width: 60px;
  }

  /* 공급가액 앞에 라벨 추가 */
  #standalone-contract-modal #sc-item-table td:nth-child(4)::before {
    content: "공급가액:";
    color: #333;
    margin-bottom: 0; /* 라벨 기본 마진 제거 */
  }

  /* 삭제 버튼이 셀을 꽉 채우도록 설정 */
  #standalone-contract-modal #sc-item-table .sc-remove-row-btn {
    width: 100%;
    height: 100%;
    margin: 0;
  }
  .site-footer .footer-content {
    font-size: 11px; /* 기존 13px에서 크기를 줄입니다. (조절 가능) */
    white-space: nowrap; /* 텍스트가 길어도 자동으로 줄바꿈되는 것을 막습니다. */
    overflow-x: auto; /* 내용이 너무 길 경우, 잘리지 않고 가로 스크롤이 생깁니다. */
    -webkit-overflow-scrolling: touch; /* iOS에서 부드러운 스크롤 효과를 줍니다. */
    padding: 0 10px; /* 스크롤 시 좌우 여백을 확보합니다. */
  }
}
