/* =====================================================================
   costs.css — 마케팅(#/marketing) · 설정 › 원가 · 수수료(#/settings/costs) 화면 (합격 기준 PL-08 · design/ERP_UI_원칙.md §5-4 · ERP-15)
   [JUDG] erp.app.css에는 '표의 줄을 펼쳐 그 자리에서 고치는 칸 묶음'(원가 단계: 시작일 · 달러 단가 × 환율 × 배수 = 원가),
   '숫자 칸 + 단위가 든 설정 표'(수수료), 달 고르기 줄이 없어 토큰만으로 만든다.
   있는 부품은 그대로 쓴다: .back · .head · .seg · .banner · .tbl(.tbl--stack · .disc · .is-child) · .fld · .inp · .row-flds · .btn · .empty · .legend · .io-won(parts.css).
   값은 모두 토큰(var(--…)) 또는 낱말 값이다. 색 · 크기 · 간격 숫자를 직접 쓰지 않는다 (시험: tests/web/costform.test.ts).
   Cowork가 erp.css로 옮기면 이 파일에서 지운다.
   ===================================================================== */

/* [JUDG] 구역 고르기의 '빠진 값' 개수 — 사이드바 배지(.nav-i__n)와 같은 뜻. 주의 색(주황) 숫자 + 화면 낭독용 글자("개 빠짐") */
.cst-n { font-size: var(--fs-footnote); line-height: var(--lh-footnote); font-weight: var(--fw-semibold); color: var(--orange); }

/* [JUDG] 줄의 짧은 꼬리표(임시 · 빠짐 · 원가 없음 · 지금 · 예정 · 저장 전 · 부가세 별도) — 상태는 글자로(ERP-04). 보조 글자 15/600, 색은 .c2 · .c-orange · .c-red가 정한다 */
.cst-tag { font-family: var(--font-sans); font-size: var(--fs-subhead); line-height: var(--lh-subhead); font-weight: var(--fw-semibold); white-space: nowrap; }

/* [JUDG] 펼침 버튼(.disc) + 이름 · 날짜 한 줄 */
.cst-name { display: inline-flex; align-items: center; gap: var(--sp-1); }

/* [JUDG] 원가 표: 이름 바로 옆에 지금 원가(숫자는 오른쪽 맞춤) — 화면 폭을 다 쓰면 이름과 숫자가 양 끝으로 멀어져 줄을 따라가기 어렵다.
   남는 폭은 마지막 열('다음')이 가져간다(본문 폭만큼 달라고 해 두면 앞의 두 열이 내용 폭으로 줄어든다) */
.cst-costs th:last-child { width: var(--w-content); }
.cst-costs .cst-name { white-space: nowrap; }
.cst-costs td .cst-tag { margin-inline-start: var(--sp-1); }

/* ── 판매가 칸(원가 표의 줄마다 하나 · 합격 기준 PL-12) ────────────────────────────────────────────────
   [JUDG] 한 칸 = 짝(꼬리표 + 값) 하나 또는 둘. 꼬리표(카페24 · 직접 넣음 · 없음 · 일부 없음)는 값 앞의 정해진 자리에 오른쪽으로 붙인다 — 자리의 폭(64 ≈ 각주 글자 다섯)을 미리 잡아
   ① 숫자의 오른쪽 끝이 줄마다 같은 선에 서고(꼬리표 길이가 달라도) ② 틀린 값의 이유(1원 이상 · 정수만 · 숫자 아님 — 빨강)가 그 자리에 떠도 칸도 줄도 밀리지 않는다(원칙 ERP-17 —
   설정의 .st-f__e는 칸 아래에 한 줄을 잡지만, 줄이 수십 개인 표에서는 줄마다 18px이 늘어나므로 옆 자리를 쓴다). 글자는 칸 아래 이유(.cst-cap)와 같은 크기.
   카페24 가격과 직접 넣는 칸이 함께 있는 상품(일부 품목에만 카페24 가격)은 두 줄 — 오른쪽 끝을 맞춘다 */
.cst-prs { display: inline-flex; flex-direction: column; align-items: flex-end; gap: var(--sp-1); vertical-align: middle; }
.cst-pr { display: inline-flex; align-items: center; gap: var(--sp-2); white-space: nowrap; }
.cst-pr__t { min-width: var(--sp-16); text-align: right; font-family: var(--font-sans); font-size: var(--fs-footnote); line-height: var(--lh-footnote); font-weight: var(--fw-semibold); color: var(--label-2); white-space: nowrap; }
.cst-pr__t.is-bad { color: var(--red); }
/* [JUDG] 입력 칸 폭 = 표 입력 칸(96 — '129,700'까지 한 줄). 글자로 보이는 값(카페24 가격 · 읽기 전용)에도 입력 칸과 같은 안쪽 여백 · 테두리 자리를 둬 숫자의 끝이 입력 칸의 숫자와 같은 선에 선다 */
.cst-price .inp { width: var(--erp-cell-in-w); padding-inline: var(--sp-3); }
.cst-pr__v { padding-inline-end: var(--sp-3); border-inline-end: thin solid transparent; }
/* [JUDG] 읽기 전용(값만)에는 꼬리표 자리를 잡지 않는다 — 떠오를 이유가 없고, 쌓아 보일 때 칸 이름 뒤에 빈 틈이 생긴다 */
.cst-prs--ro .cst-pr__t { min-width: initial; }

/* [JUDG] 펼친 줄(.is-child) 안의 여백 — .tbl의 칸 여백(위아래 4)은 입력 칸 묶음에는 좁고, 휴대폰의 쌓기 표는 여백이 없다 */
.cst-costs tr.is-child td, .cst-exps tr.is-child td { padding: var(--sp-3) var(--sp-4) var(--sp-4); }

/* ── 원가 단계 ─────────────────────────────────────────────────────────────────────────
   [JUDG] 한 단계 = 한 줄: [꼬리표 · 시작일] [달러 단가 × 환율 × 배수 = 장당 원가] [임시 · 지우기]. 계산식이 그대로 보여 환율만 바꾸면 원가가 바뀌는 것을 읽지 않고 안다.
   좁으면 세 묶음이 차례로 다음 줄로 내려간다. 단계 사이는 가는 선 하나 */
.cst-steps { display: flex; flex-direction: column; gap: var(--sp-3); }
.cst-step { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--sp-2) var(--sp-5); }
.cst-step + .cst-step { padding-top: var(--sp-3); border-top: thin solid var(--sep); }
.cst-step__when, .cst-step__calc, .cst-step__end, .cst-eq { display: flex; align-items: flex-start; gap: var(--sp-2) var(--sp-3); }
.cst-step__calc { flex-wrap: wrap; }
/* [JUDG] 칸 이름은 칸 위에 늘 보이되(HIG-FORM-01) 단계마다 되풀이되므로 가볍게 — 각주 크기 · 회색 */
.cst-step .fld { gap: var(--sp-1); }
.cst-step .fld__l { font-size: var(--fs-footnote); line-height: var(--lh-footnote); font-weight: var(--fw-regular); color: var(--label-2); }
/* [JUDG] 칸 폭: 숫자 칸 = 표 입력 칸 폭(96 — '1,350' · '2.305'), 배수 = 재고 칸 폭(76 — '1.3'), 시작일 = 날짜 칸(120 + 48), 원화 원가 = 숫자 칸(120) */
.cst-f .inp { width: var(--erp-cell-in-w); padding-inline: var(--sp-3); text-align: right; }
.cst-f--from .inp { width: calc(var(--sp-30) + var(--sp-12)); text-align: left; }
.cst-f--factor .inp { width: var(--erp-cell-w); }
.cst-f--cost .inp { width: var(--sp-30); }
/* [JUDG] 칸 이름 줄(각주 18 + 4) 아래, 입력 칸과 같은 높이에 놓이는 것들: 꼬리표 · 연산 기호 · 임시/지우기 */
.cst-step__tag, .cst-op, .cst-step__end { margin-top: calc(var(--lh-footnote) + var(--sp-1)); min-height: var(--erp-row); }
.cst-step__tag, .cst-op { display: inline-flex; align-items: center; }
.cst-step__tag { min-width: var(--sp-12); }
.cst-step__end { align-items: center; }
.cst-op { color: var(--label-2); }
/* [JUDG] 계산한 원가 — 입력 칸이 아니라 결과라 테두리 없이 굵게(숫자가 주인공 · ERP-02) */
.cst-out { display: flex; align-items: center; min-height: var(--erp-row); min-width: var(--erp-cell-w); font-size: var(--fs-body); line-height: var(--lh-body-tight); font-weight: var(--fw-semibold); color: var(--label); white-space: nowrap; }
/* [JUDG] 틀린 칸 아래의 짧은 이유(2~6자) — 빨간 테두리(.inp[aria-invalid])와 함께. 색만으로 알리지 않는다 */
.cst-cap { font-size: var(--fs-footnote); line-height: var(--lh-footnote); font-weight: var(--fw-semibold); color: var(--red); white-space: nowrap; }
/* [JUDG] 덜 넣은 새 단계: 무엇을 넣으면 저장되는지 한 줄(주의 색 = 아직 저장하지 않음) */
.cst-wait { font-size: var(--fs-footnote); line-height: var(--lh-footnote); color: var(--orange); }
/* [JUDG] 저장된 단계의 칸을 비우고 나갔을 때의 한 줄(비운 칸을 저장된 값으로 되돌렸다 · 지우는 길은 [지우기]) — 오류도 '저장 전'도 아니라 안내라서 보조 글자색 · 각주 크기.
   화면이 '저장 전'이라고 말하는데 서버는 옛 원가를 쓰는 일을 없앤 자리다(2026-11-28 실사용 시험) */
.cst-hint { font-size: var(--fs-footnote); line-height: var(--lh-footnote); color: var(--label-2); }
/* [JUDG] 켜고 끄는 값 하나(임시 · 부가세 포함) — 눌리는 곳 44, 글자와 함께 누른다. 상자 크기는 표 첫 열 체크(.chk)와 같다 */
.cst-chk { display: inline-flex; align-items: center; gap: var(--sp-2); min-height: var(--erp-row); padding-inline-end: var(--sp-2); font-size: var(--fs-body); line-height: var(--lh-body-tight); color: var(--label); white-space: nowrap; cursor: pointer; }
.cst-chk input { flex: none; width: var(--sp-5); height: var(--sp-5); margin: initial; accent-color: var(--accent); cursor: pointer; }
.cst-acts { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-4); }

/* ── 수수료 ─────────────────────────────────────────────────────────────────────────────
   [JUDG] 표 폭은 읽기 폭까지 — 화면 폭을 다 쓰면 이름과 그 줄의 숫자 칸이 멀어져 줄을 따라가기 어렵다 */
.cst-fees { max-width: var(--w-read); }
.cst-h { margin-block: var(--sp-6) var(--sp-1); padding-inline-start: var(--sp-3); font-size: var(--fs-subhead); line-height: var(--lh-subhead); font-weight: var(--fw-semibold); color: var(--label-2); }
.cst-h:first-of-type { margin-top: initial; }
/* [JUDG] 숫자 칸 + 단위(% · 원) — 단위는 칸 밖에(원칙 §4 입력 칸) */
.cst-unit { display: inline-flex; align-items: center; gap: var(--sp-2); }
.cst-fees .cst-cap { display: block; padding-inline-end: var(--sp-6); }
/* [JUDG] 칸 아래에 이유가 붙어 줄이 높아져도 같은 줄의 두 칸과 이름이 나란하게 — 위를 맞추고, 이름은 입력 칸 높이의 가운데에 */
.cst-fees td { vertical-align: top; }
.cst-fee-n { display: inline-flex; align-items: center; gap: var(--sp-1); min-height: var(--erp-row); }

/* ── 마케팅 ─────────────────────────────────────────────────────────────────────────────
   [JUDG] 달 고르기 한 줄: ‹ 2026년 11월 › · 오른쪽 끝에 그 달 마케팅비 합계 — 이 화면에서 가장 큰 숫자(화면 제목과 같은 크기 · 상황이 읽지 않아도 보이게) */
.cst-month { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.cst-month__t { min-width: calc(var(--sp-30) + var(--sp-2)); text-align: center; }
.cst-month__sum { margin-inline-start: auto; font-size: var(--fs-subhead); line-height: var(--lh-eyebrow); color: var(--label-2); white-space: nowrap; }
.cst-month__sum strong { margin-inline-start: var(--sp-2); font-size: var(--fs-eyebrow); letter-spacing: var(--ls-eyebrow); font-weight: var(--fw-semibold); color: var(--label); }
/* [JUDG] 내역 칸은 문장이 들어가니 날짜 · 금액보다 넓게(오른쪽 패널 폭부터) */
.row-flds > .cst-memo { flex-basis: var(--erp-panel-w); }
/* [JUDG] 넣기 묶음 — 설정의 그룹 상자(.grp)와 같은 바탕 · 반경. 아래 줄: 부가세 포함(왼쪽) · 주 버튼(오른쪽 끝) */
.cst-add { display: flex; flex-direction: column; gap: var(--sp-3); margin-bottom: var(--sp-6); padding: var(--sp-4); border-radius: var(--r-card); background: var(--bg-2); }
.cst-add__end { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--sp-3); }
.cst-exps tr.is-child .row-flds { margin-bottom: var(--sp-2); }

/* ── 읽기 전용(관리자가 아닌 사람 — 사용자 결정 2026-11-27: 손익은 모든 역할이 본다) ───────────────────
   [JUDG] 입력 칸 대신 글자. 원가 단계: 한 줄 = 꼬리표(지금 · 예정 · 지난) · 시작일 · ($ × 환율 × 배수 =) 원가 · 임시. 수수료: 입력 칸이 없으니 줄 가운데 맞춤 */
.cst-ro { display: flex; flex-direction: column; gap: var(--sp-2); margin: initial; padding: initial; list-style: none; font-size: var(--fs-body); line-height: var(--lh-body-tight); }
.cst-ro__i { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-1) var(--sp-4); }
.cst-ro__tag { min-width: var(--sp-12); }
.cst-fees--ro td { vertical-align: middle; }

/* ── 휴대폰(734px 이하) ─────────────────────────────────────────────────────────────────── */
@media (max-width: 734px) {
  /* [JUDG] 원가 표: 이름과 지금 원가를 한 줄에(쌓기 표의 기본은 칸마다 한 줄이라 상품 열둘이 화면 넷을 넘긴다). 긴 이름은 줄을 바꾸고, 빈 '다음' 칸은 자리를 차지하지 않는다 */
  .cst-costs tr, .cst-exps tr { align-items: center; }
  .cst-costs .cst-name { white-space: normal; word-break: keep-all; }
  .cst-costs td:empty { display: none; }
  /* [JUDG] 판매가 칸(셋째 칸)은 이름 아래 왼쪽에 — 쌓기 표에서는 첫 열(남는 폭)에 놓이므로 오른쪽 맞춤이면 줄 가운데에 뜬다. 칸 이름('판매가 · ')이 앞에 붙는다 */
  .cst-costs td.cst-price { text-align: left; }
  .cst-costs .cst-prs { align-items: flex-start; }
  /* [JUDG] 수수료 표: 이름 · 요율 · 장당(건당) 칸을 한 줄에 — 이름이 남는 폭을 쓰고 두 칸은 내용 폭. 칸 이름(요율 · 장당 비용)은 칸 위에, 칸 폭은 한 단계 좁게.
     칸 아래에 이유가 붙어도 입력 칸끼리는 나란하게 위를 맞추고, 이름은 입력 칸 줄에 맞춘다 */
  .cst-fees tr { grid-template-columns: auto max-content max-content; align-items: start; }
  .cst-fees td:first-child { align-self: end; }
  .cst-fees td[data-l]::before { content: attr(data-l); display: block; }
  .cst-fees .inp--num { width: var(--sp-20); }
  .cst-fees .cst-cap { padding-inline-end: initial; }
  /* [JUDG] 원가 단계의 숫자 칸 셋(달러 단가 × 환율 × 배수)이 한 줄에 들어가게 한 단계 좁게 */
  .cst-step__calc .cst-f .inp { width: var(--erp-cell-w); padding-inline: var(--sp-2); }
  .cst-step__calc .cst-f--cost .inp { width: var(--sp-30); }
  .cst-step__calc { gap: var(--sp-2); }
  /* [JUDG] 묶음이 줄마다 쌓이면 '칸 이름 줄만큼 내리기'가 빈 틈이 된다 — 임시 · 지우기 줄은 바로 붙인다 */
  .cst-step__end { margin-top: initial; align-self: flex-end; }
  .cst-costs tr.is-child td, .cst-exps tr.is-child td { padding: var(--sp-3); }
  .cst-add__end .btn { flex: auto; }
}

/* ── 좁은 PC 창(735 ~ 1068px — 사이드바 200 · 본문 471 ~ 804px) ───────────────────────────────────────────
   [JUDG] 원가 표에 판매가 칸이 하나 늘어(꼬리표 자리 64 + 입력 칸 96 + 단위) 네 칸이 한 줄에 서지 못한다: 상품 이름(줄바꿈 없음 ~ 280) + 지금 원가(~ 130) + 판매가(~ 215 · 범위가 있으면 ~ 245) +
   다음(줄을 바꿔도 75)이 700을 넘어 표가 화면 밖으로 넘친다(본문은 1068에서도 804). → 줄을 두 줄로 쌓는다: 첫 줄 = 상품 이름 · 지금 원가(오른쪽 끝), 둘째 줄 = 다음(왼쪽) · 판매가(오른쪽 끝).
   머리글 줄은 감추고 칸 이름을 숫자 앞에 붙인다(원가 · 판매가 · 다음 — 휴대폰의 쌓기 표와 같은 방식). 734 이하는 정식 부품의 쌓기 표(.tbl--stack)가 맡고, 1069부터는 보통 표다.
   block으로 바꾼 칸은 모두 height: auto — 표의 칸에서는 줄 높이(52)가 '적어도'지만 block이 되면 '딱 그만큼'이라 펼친 줄의 칸 묶음이 아래 줄을 덮는다(마케팅 목록의 F2 · 2026-12-02) */
@media (min-width: 735px) and (max-width: 1068px) {
  .cst-costs, .cst-costs tbody { display: block; }
  .cst-costs thead { display: none; }
  .cst-costs tr:not(.is-child) { display: grid; grid-template-columns: auto max-content; grid-template-areas: "name now" "next price"; align-items: center; border-bottom: thin solid var(--sep); }
  .cst-costs tr:not(.is-child) td { display: block; height: auto; border-bottom: none; }
  .cst-costs tr:not(.is-child) td:first-child { grid-area: name; }
  .cst-costs tr:not(.is-child) td.cst-now { grid-area: now; }
  .cst-costs tr:not(.is-child) td.cst-price { grid-area: price; }
  .cst-costs tr:not(.is-child) td.wide { grid-area: next; }
  .cst-costs tr:not(.is-child) td:empty { display: none; }
  .cst-costs td[data-l]::before { content: attr(data-l) " · "; color: var(--label-2); font-size: var(--fs-footnote); font-weight: var(--fw-regular); }
  .cst-costs .cst-name { white-space: normal; word-break: keep-all; }
  .cst-costs tr.is-child { display: block; }
  .cst-costs tr.is-child td { display: block; height: auto; }
}
