/* ==========================================================
   스마트79 — Editor (Document Engine) CSS
   #screen-estimate 전용 스타일
   px 고정값 금지 (border 제외) / inline style 금지
   ========================================================== */

#screen-estimate {
  background: var(--gray-bg);
}

/* ==========================================================
   헤더 + 문서탭
   ========================================================== */
#main-hdr {
  background: var(--blue-grad);
  padding: var(--sp-xl) var(--sp-lg) var(--sp-md);
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}
.hdr-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-sm);
}
.hdr-btn-icon {
  width: var(--btn-h-sm);
  height: var(--btn-h-sm);
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: 1.5px solid rgba(255,255,255,0.4);
  color: var(--white);
  font-size: var(--fs-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.editor-title {
  font-size: var(--fs-xl);
  font-weight: 800;
  color: var(--white);
  flex: 1;
  text-align: center;
}
.hdr-btns {
  display: flex;
  gap: var(--sp-xs);
  flex-shrink: 0;
}

/* 문서 탭 */
.doc-tabs {
  display: flex;
  gap: var(--sp-xs);
  background: rgba(0,0,0,0.15);
  border-radius: var(--radius);
  padding: var(--sp-xs);
}
.doc-tab {
  flex: 1;
  height: var(--btn-h-md);
  font-size: var(--fs-sm);
  font-weight: 700;
  color: rgba(255,255,255,0.7);
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  transition: all 0.2s;
}
.doc-tab.active {
  background: var(--white);
  color: var(--blue);
}

/* ==========================================================
   서브뷰 (편집 / 목록)
   ========================================================== */
.editor-view {
  display: none;
}
.editor-view.active {
  display: block;
}

/* ==========================================================
   섹션 공통
   ========================================================== */
.section {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: var(--sp-sm);
  overflow: hidden;
}
.section-hdr {
  padding: var(--sp-sm) var(--sp-md);
  background: var(--blue-light);
  border-bottom: 1px solid var(--gray-border);
}
.section-hdr h2 {
  font-size: var(--fs-md);
  font-weight: 800;
  color: var(--blue);
}
.section-body {
  padding: var(--sp-md);
}

/* ==========================================================
   기본정보 (info-row)
   ========================================================== */
.info-row {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-sm);
}
.info-row:last-child {
  margin-bottom: 0;
}
.info-label {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text-sub);
  width: clamp(48px, 12vw, 64px);
  flex-shrink: 0;
}
.info-input {
  flex: 1;
  min-width: 0;
  padding: var(--sp-sm) var(--sp-md);
  font-size: var(--fs-md);
  border: 1.5px solid var(--gray-border);
  border-radius: var(--radius-sm);
  background: var(--gray-bg);
  color: var(--text);
  cursor: pointer;
}
.info-input:focus { border-color: var(--blue); }

.info-row-date {
  flex-wrap: nowrap;
}
.info-input-date {
  flex: 1.4;
  text-align: center;
}
.info-input-date-sm {
  flex: 1;
  text-align: center;
}
.info-date-sep {
  font-size: var(--fs-sm);
  color: var(--text-sub);
  flex-shrink: 0;
}

/* ==========================================================
   품목 테이블 (.it)
   ========================================================== */
.it-wrap {
  overflow-x: auto;
  margin-bottom: var(--sp-sm);
}
.it {
  width: 100%;
  min-width: clamp(420px, 110vw, 640px);
  border-collapse: collapse;
}
.it th {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-sub);
  background: var(--gray-bg);
  padding: var(--sp-xs) var(--sp-sm);
  border-bottom: 1px solid var(--gray-border);
  text-align: center;
  white-space: nowrap;
}
.it td {
  padding: var(--sp-xs);
  border-bottom: 1px solid var(--gray-border);
}
.it-field {
  width: 100%;
  min-width: clamp(56px, 14vw, 80px);
  padding: var(--sp-xs) var(--sp-sm);
  font-size: var(--fs-sm);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-sm);
  background: var(--gray-bg);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.it-field.it-num {
  text-align: right;
  min-width: clamp(48px, 11vw, 64px);
}
.it-amount {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text);
  text-align: right;
  white-space: nowrap;
  padding: var(--sp-xs) var(--sp-sm);
  min-width: clamp(64px, 16vw, 88px);
}
.btn-remove-item {
  width: clamp(28px, 7vw, 36px);
  height: clamp(28px, 7vw, 36px);
  border-radius: 50%;
  background: #fee;
  color: var(--red);
  font-size: var(--fs-sm);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-add-item {
  width: 100%;
  padding: var(--sp-sm);
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--blue);
  background: var(--blue-light);
  border: 1.5px dashed var(--blue);
  border-radius: var(--radius-sm);
}

/* ==========================================================
   금액계산 (.tt)
   ========================================================== */
.tt {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-sm) 0;
  border-bottom: 1px solid var(--gray-border);
  font-size: var(--fs-sm);
}
.tt:last-of-type {
  border-bottom: none;
}
.tt-label {
  flex: 1;
  font-weight: 700;
  color: var(--text-sub);
}
.tt-value {
  font-weight: 800;
  color: var(--text);
  text-align: right;
  white-space: nowrap;
}
.tt-grand .tt-label,
.tt-grand .tt-value {
  font-size: var(--fs-lg);
  color: var(--blue);
}
.tt-rate {
  width: clamp(44px, 11vw, 60px);
  padding: var(--sp-xs) var(--sp-sm);
  font-size: var(--fs-sm);
  text-align: center;
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-sm);
  background: var(--gray-bg);
  color: var(--text);
  cursor: pointer;
}
.tt-unit {
  font-size: var(--fs-xs);
  color: var(--text-sub);
  flex-shrink: 0;
}
.tt-vat-toggle {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  font-size: var(--fs-xs);
  color: var(--text-sub);
  cursor: pointer;
}
.tt-vat-toggle input {
  width: clamp(16px, 4vw, 18px);
  height: clamp(16px, 4vw, 18px);
}

/* 절사 */
.trunc-row {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  margin-top: var(--sp-sm);
  flex-wrap: wrap;
}
.trunc-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-sub);
  margin-right: var(--sp-xs);
}
.trunc-btn {
  padding: var(--sp-xs) var(--sp-sm);
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-sub);
  background: var(--gray-bg);
  border: 1.5px solid var(--gray-border);
  border-radius: 999px;
}
.trunc-btn.active {
  color: var(--white);
  background: var(--blue);
  border-color: var(--blue);
}

/* ==========================================================
   저장 버튼
   ========================================================== */
.editor-save-btn {
  margin: var(--sp-sm);
  width: calc(100% - 2 * var(--sp-sm));
}

/* ==========================================================
   목록 뷰
   ========================================================== */
.list-hdr {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-md);
}
.list-back-btn {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--blue);
  background: var(--blue-light);
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--sp-xs) var(--sp-md);
}
.list-title {
  font-size: var(--fs-md);
  font-weight: 800;
  color: var(--text);
}
.list-loading {
  text-align: center;
  padding: var(--sp-xl);
  font-size: var(--fs-sm);
  color: var(--text-sub);
}
.list-item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 0 var(--sp-sm) var(--sp-sm);
  padding: var(--sp-md);
  cursor: pointer;
}
.list-item-main {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding-right: var(--sp-2xl);
}
.list-item-type {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--blue);
  background: var(--blue-light);
  border-radius: var(--radius-sm);
  padding: 2px var(--sp-xs);
  flex-shrink: 0;
}
.list-item-title {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-item-meta {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-xs);
  color: var(--text-sub);
}
.list-item-grand {
  font-weight: 700;
  color: var(--text);
}
.list-item-del {
  position: absolute;
  top: var(--sp-sm);
  right: var(--sp-sm);
  width: clamp(28px, 7vw, 36px);
  height: clamp(28px, 7vw, 36px);
  border-radius: 50%;
  background: #fee;
  border: none;
  font-size: var(--fs-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================
   Breakpoints
   ========================================================== */
@media (min-width: 985px) {
  #screen-edit {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-md);
    padding: var(--sp-md);
    align-items: start;
  }
  #screen-edit .section {
    margin: 0;
  }
  #screen-edit .section:nth-child(2) {
    grid-column: 1 / -1;
  }
  #screen-edit .editor-save-btn,
  #screen-edit #editor-save-msg {
    grid-column: 1 / -1;
    margin: 0;
  }
}
