/* 발주스플릿 — 업무용 화면. 그림자 없음, 모서리 4px 이하, 포인트 컬러는 남색 하나. */
:root {
  --bg: #ffffff;
  --bg-2: #f7f7f8;          /* 표 머리글·호버 */
  --bg-3: #efeff1;
  --line: #e4e4e7;
  --line-2: #d4d4d8;
  --text: #18181b;
  --text-2: #3f3f46;
  --muted: #5f5f68;         /* 흰 배경 대비 6.3:1 */
  --accent: #1e3a8a;        /* 짙은 남색 */
  --accent-hover: #172f70;
  --accent-text: #ffffff;
  --accent-bg: #eef2fb;
  --danger: #b42318;
  --danger-bg: #fdf1f0;
  --warn: #8a4b00;
  --warn-bg: #fdf6e7;
  --ok: #1a6b3c;
  --sheet-head: #f3f3f5;
  --sheet-line: #e2e2e6;
  --focus: #1e3a8a;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #18181b;
    --bg-2: #1f1f23;
    --bg-3: #27272a;
    --line: #34343a;
    --line-2: #45454d;
    --text: #f4f4f5;
    --text-2: #d4d4d8;
    --muted: #a8a8b1;
    --accent: #93acee;
    --accent-hover: #adc0f3;
    --accent-text: #111318;
    --accent-bg: #222a3d;
    --danger: #f2877b;
    --danger-bg: #2e1d1c;
    --warn: #eab562;
    --warn-bg: #2c2416;
    --ok: #7fcf9b;
    --sheet-head: #222226;
    --sheet-line: #34343a;
    --focus: #93acee;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #18181b;
  --bg-2: #1f1f23;
  --bg-3: #27272a;
  --line: #34343a;
  --line-2: #45454d;
  --text: #f4f4f5;
  --text-2: #d4d4d8;
  --muted: #a8a8b1;
  --accent: #93acee;
  --accent-hover: #adc0f3;
  --accent-text: #111318;
  --accent-bg: #222a3d;
  --danger: #f2877b;
  --danger-bg: #2e1d1c;
  --warn: #eab562;
  --warn-bg: #2c2416;
  --ok: #7fcf9b;
  --sheet-head: #222226;
  --sheet-line: #34343a;
  --focus: #93acee;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  word-break: keep-all;
  overflow-wrap: anywhere;
  overflow-x: hidden;
}
h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { display: block; }
[hidden] { display: none !important; }

/* ---------- 헤더 ---------- */
.appbar { border-bottom: 1px solid var(--line); background: var(--bg); }
.appbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap;
}
.logo {
  display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none;
  font-size: 18px; letter-spacing: -0.03em; line-height: 1;
}
/* "스플릿"은 500 + 70% 불투명, "발주"는 800 + 본래 색 */
.logo-text { font-weight: 500; color: color-mix(in srgb, var(--text) 70%, transparent); }
.logo-text b { font-weight: 800; color: var(--text); }
.appbar-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.tabbar { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--line); }
.tabs { max-width: 1240px; margin: 0 auto; padding: 0 20px; display: flex; gap: 4px; overflow-x: auto; }
.tab {
  appearance: none; background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 12px 12px 10px; font-size: 14.5px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- 소개 · 문의 (회색 테두리 박스 하나) ---------- */
.intro-wrap { max-width: 1240px; margin: 0 auto; padding: 16px 20px 4px; }
.intro, .contact {
  display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: 4px; padding: 16px 18px; background: var(--bg);
}
.intro-text { flex: 1; min-width: 240px; }
.intro h1 { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.intro p { font-size: 14px; color: var(--muted); margin-top: 2px; }
.intro-actions { display: flex; align-items: center; gap: 8px; }
.contact { margin-top: 32px; }
.contact p { font-size: 14px; color: var(--text-2); flex: 1; min-width: 240px; }
a.btn { text-decoration: none; }

/* ---------- 테마 전환 ---------- */
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 4px; overflow: hidden; margin-left: 6px; }
.seg button {
  appearance: none; border: 0; background: var(--bg); color: var(--muted);
  height: 30px; padding: 0 10px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button:hover { color: var(--text); }
.seg button[aria-checked="true"] { background: var(--accent-bg); color: var(--accent); }

/* ---------- 버튼 · 입력 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 4px;
  background: var(--bg); color: var(--text); font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--bg-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn.quiet:hover { color: var(--text); background: var(--bg-2); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-bg); }
.btn.lg { height: 40px; padding: 0 18px; font-size: 14.5px; }
.btn.sm { height: 28px; padding: 0 9px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn {
  width: 28px; height: 28px; display: inline-grid; place-items: center; border: 1px solid var(--line-2); border-radius: 4px;
  background: var(--bg); color: var(--text-2); cursor: pointer; padding: 0; vertical-align: middle;
}
.icon-btn:hover { background: var(--bg-2); color: var(--text); }
.icon-btn.del:hover { color: var(--danger); background: var(--danger-bg); }
.icon-btn:disabled { opacity: .35; cursor: default; background: var(--bg); }
.icon-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

.input {
  width: 100%; height: 32px; padding: 0 9px; border: 1px solid var(--line-2); border-radius: 4px;
  background: var(--bg); color: var(--text); font-size: 13.5px; min-width: 0;
}
.input::placeholder { color: var(--muted); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
textarea.input { height: auto; min-height: 32px; padding: 6px 9px; line-height: 1.45; resize: vertical; }
select.input {
  appearance: none; -webkit-appearance: none; padding-right: 28px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 10px) 50%;
  background-size: 4px 4px; background-repeat: no-repeat;
}
select.input option, select.input optgroup { background: var(--bg); color: var(--text); }
.input.err { border-color: var(--danger); }
.mark-req { color: var(--danger); font-size: 13px; font-weight: 700; margin-left: 4px; }

/* ---------- 페이지 ---------- */
.page { max-width: 1240px; margin: 0 auto; padding: 20px 20px 0; }
.lib-error { padding: 10px 12px; margin-bottom: 16px; border: 1px solid var(--danger); border-radius: 4px; color: var(--danger); background: var(--danger-bg); font-weight: 600; }
.foot { color: var(--muted); font-size: 13px; padding: 24px 0 40px; }

/* ---------- 단계 (한 번에 하나만 펼침) ---------- */
.steps { border: 1px solid var(--line); border-radius: 4px; }
.step { scroll-margin-top: 56px; }
.step + .step { border-top: 1px solid var(--line); }
.step-head {
  width: 100%; display: grid; grid-template-columns: 26px auto minmax(0, 1fr) auto; align-items: center; gap: 4px 12px;
  padding: 14px 18px; background: var(--bg); border: 0; text-align: left; cursor: pointer; color: var(--text);
}
.step-head:hover { background: var(--bg-2); }
.step:first-child .step-head { border-radius: 4px 4px 0 0; }
.step:last-child:not(.open) .step-head { border-radius: 0 0 4px 4px; }
.step-no {
  width: 24px; height: 24px; border-radius: 4px; display: grid; place-items: center;
  border: 1px solid var(--line-2); color: var(--muted); font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums;
}
.step-no svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.step.done .step-no { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.step.open .step-no { border-color: var(--accent); color: var(--accent); }
.step.open.done .step-no { color: var(--accent-text); }
.step-title { font-size: 15px; font-weight: 700; white-space: nowrap; }
.step-sum { font-size: 13.5px; color: var(--muted); min-width: 0; }
.step-sum .bad { color: var(--danger); font-weight: 600; }
.step-sum .sep { color: var(--line-2); margin: 0 6px; }
.step-act { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.step-body { padding: 0 18px 22px 56px; }
.step-foot { display: flex; justify-content: flex-end; gap: 8px; padding-top: 18px; margin-top: 24px; border-top: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.step-foot .hint { margin-right: auto; color: var(--muted); font-size: 13px; }

/* 단계 안의 소단원: 박스 없이 제목 + 구분선 */
.sec { padding-top: 18px; }
.sec + .sec { margin-top: 26px; border-top: 1px solid var(--line); padding-top: 22px; }
.sec-h { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px 16px; margin-bottom: 12px; flex-wrap: wrap; }
.sec-h h3 { font-size: 15px; font-weight: 700; }
.sec-h p { font-size: 13px; color: var(--muted); margin-top: 2px; }
.sec-h .tools { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.prio { font-size: 13px; color: var(--muted); padding-top: 14px; }
.prio b { color: var(--text-2); font-weight: 600; }
.prio .gt { margin: 0 6px; }
.note { font-size: 13px; color: var(--muted); }
.note.err { color: var(--danger); font-weight: 600; }
.subhead { font-size: 13.5px; font-weight: 700; margin: 20px 0 8px; color: var(--text-2); display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.subhead .note { font-weight: 400; }

/* ---------- 업로드 ---------- */
.dropzone {
  display: flex; align-items: center; justify-content: center; gap: 12px; text-align: left;
  padding: 26px 18px; border: 1px dashed var(--line-2); border-radius: 4px; background: var(--bg-2); cursor: pointer;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-bg); }
.dropzone svg { width: 28px; height: 28px; flex: none; fill: none; stroke: var(--muted); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.dropzone strong { display: block; font-size: 14.5px; }
.dropzone span { font-size: 13px; color: var(--muted); }
.privacy-line { font-size: 13px; color: var(--muted); margin-top: 8px; }
.inline-actions { display: flex; gap: 6px 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; font-size: 13px; color: var(--muted); }
.file-line { display: flex; align-items: center; gap: 8px 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px; flex-wrap: wrap; }
.file-line .name { font-weight: 700; }
.file-line .meta { color: var(--muted); font-size: 13px; }
.file-line .grow { flex: 1; min-width: 200px; }
.ext { font-size: 13px; font-weight: 700; padding: 0 5px; border: 1px solid var(--line-2); border-radius: 3px; color: var(--muted); }

/* ---------- 폼 표 (컬럼 매핑, 송장 열 설정) ---------- */
.form-table { width: 100%; border-collapse: collapse; border: 1px solid var(--line); }
.form-table th, .form-table td { border-bottom: 1px solid var(--line); padding: 6px 12px; text-align: left; vertical-align: middle; height: 46px; }
.form-table thead th { background: var(--sheet-head); font-size: 13px; color: var(--muted); font-weight: 600; height: 36px; }
.form-table tbody th { width: 30%; font-weight: 600; font-size: 14px; border-right: 1px solid var(--line); }
.form-table tr.req-missing th { color: var(--danger); }
.form-table tr.group td { height: auto; padding: 6px 12px; background: var(--bg-2); font-size: 13px; color: var(--muted); font-weight: 600; }
.cellflex { display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; }
.cellflex .input { max-width: 320px; }
.cellflex .ex { font-size: 13px; color: var(--muted); }
.cellflex .ex.err { color: var(--danger); font-weight: 600; }

/* ---------- 편집 표 (출력 열, 연결 규칙, 옵션) ---------- */
.edit-wrap { overflow-x: auto; border: 1px solid var(--line); }
.edit-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.edit-table th, .edit-table td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: middle; }
.edit-table thead th { background: var(--sheet-head); font-size: 13px; color: var(--muted); font-weight: 600; height: 34px; white-space: nowrap; }
.edit-table tbody tr:last-child td { border-bottom: 0; }
.edit-table td.idx { width: 44px; text-align: center; color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.edit-table td.ctrl { width: 1%; white-space: nowrap; }
.edit-table td.ctrl .icon-btn + .icon-btn { margin-left: 4px; }
.edit-table td.ex { color: var(--text-2); font-size: 13px; min-width: 160px; }
.edit-table td.ex .lbl { color: var(--muted); margin-right: 6px; }
.edit-table td.stat { font-size: 13px; color: var(--muted); min-width: 120px; }
.edit-table td.stat .bad { color: var(--danger); font-weight: 600; display: block; }
.edit-table td.name { font-weight: 600; white-space: nowrap; }
.edit-table td.top { vertical-align: top; padding-top: 10px; }
.edit-table .empty-row td { color: var(--muted); padding: 14px 10px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--c); margin-right: 7px; vertical-align: 1px; }
.below-table { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; align-items: center; }
.below-table select.input { width: auto; max-width: 100%; min-width: 220px; }

/* ---------- 시트 표 (원본·결과: 행 번호, 고정 헤더, 셀 테두리, 가로 스크롤) ---------- */
.sheet { overflow: auto; max-height: 460px; border: 1px solid var(--sheet-line); background: var(--bg); }
.sheet table { border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 100%; }
.sheet th, .sheet td {
  height: 32px; padding: 5px 10px; white-space: nowrap; text-align: left; vertical-align: middle;
  border-right: 1px solid var(--sheet-line); border-bottom: 1px solid var(--sheet-line); background: var(--bg);
}
.sheet thead th { position: sticky; top: 0; z-index: 2; background: var(--sheet-head); font-weight: 600; color: var(--text-2); }
.sheet .rn { position: sticky; left: 0; z-index: 1; background: var(--sheet-head); color: var(--muted); text-align: center; font-weight: 500; min-width: 48px; font-variant-numeric: tabular-nums; }
.sheet thead .rn { z-index: 3; }
.sheet td.n { text-align: right; font-variant-numeric: tabular-nums; }
.sheet td.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }
.sheet td.err { color: var(--danger); background: var(--danger-bg); font-weight: 600; }
.sheet td.warn { color: var(--warn); background: var(--warn-bg); font-weight: 600; }
.sheet td.ref { color: var(--muted); }
.sheet th.ref { color: var(--muted); font-weight: 500; }
.sheet td select.input { height: 26px; font-size: 13px; min-width: 210px; }
.sheet .col-tag { font-weight: 500; color: var(--accent); margin-left: 6px; }

/* ---------- 요약 ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); }
.stats > div { padding: 12px 14px; min-width: 0; }
.stats > div + div { border-left: 1px solid var(--line); }
.stats .k { font-size: 13px; color: var(--muted); }
.stats .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stats .v small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.stats .bad .v, .stats .bad .k { color: var(--danger); }
.stats .warn .v { color: var(--warn); }
.check-line { display: flex; align-items: center; gap: 6px 10px; margin-top: 10px; font-size: 13.5px; flex-wrap: wrap; }
.check-line svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.check-line.ok b, .check-line.ok svg { color: var(--ok); }
.check-line.bad b, .check-line.bad svg { color: var(--danger); }
.check-line .eq { color: var(--text-2); font-variant-numeric: tabular-nums; }
.action-row { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; margin-top: 16px; }
.action-row .note { flex: 1; min-width: 220px; }

/* ---------- 결과·파일 탭 ---------- */
.rtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.rtab {
  appearance: none; background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  padding: 9px 12px; font-size: 13.5px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.rtab:hover { color: var(--text); }
.rtab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.rtab .cnt { font-weight: 500; margin-left: 5px; font-variant-numeric: tabular-nums; }
.rtab.bad, .rtab.bad[aria-selected="true"] { color: var(--danger); }
.rtab.bad[aria-selected="true"] { border-bottom-color: var(--danger); }
.rtab.warn, .rtab.warn[aria-selected="true"] { color: var(--warn); }
.rtab.warn[aria-selected="true"] { border-bottom-color: var(--warn); }
.rpanel { padding-top: 14px; }
.rpanel-h { display: flex; align-items: center; justify-content: space-between; gap: 8px 14px; margin-bottom: 10px; flex-wrap: wrap; }
.rpanel-h .meta { font-size: 13px; color: var(--muted); }
.rpanel-h .meta b { color: var(--text); font-weight: 600; }
.rpanel-h .msg { font-weight: 600; }
.rpanel-h.bad .msg { color: var(--danger); }
.rpanel-h.warn .msg { color: var(--warn); }
.rpanel-h .msg span { display: block; font-weight: 400; color: var(--text-2); font-size: 13px; }
.rpanel-h .tools { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- 토스트 ---------- */
.toast-host { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 6px; z-index: 50; width: min(460px, calc(100vw - 32px)); }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 4px; font-size: 13.5px; }
.toast.error { background: var(--danger); color: #fff; }

/* ---------- 반응형 ---------- */
@media (max-width: 860px) {
  .step-head { grid-template-columns: 26px minmax(0, 1fr) auto; }
  .step-sum { grid-column: 2 / -1; grid-row: 2; }
  .step-body { padding: 0 16px 20px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats > div:nth-child(3) { border-left: 0; }
  .stats > div:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@media (max-width: 640px) {
  .appbar-inner { padding: 10px 16px; }
  .intro-wrap { padding: 12px 16px 4px; }
  .intro-actions, .contact .btn { width: 100%; }
  .intro-actions .btn { flex: 1; }
  .tabs, .page { padding-left: 16px; padding-right: 16px; }
  .appbar-actions { width: 100%; }
  .seg { margin-left: auto; }
  .step-head { padding: 12px 14px; }
  .step-body { padding: 0 14px 18px; }
  .form-table tbody th { width: 38%; padding: 6px 10px; font-size: 13.5px; }
  .form-table td { padding: 6px 10px; }
  .step-foot .btn { flex: 1; }
  .dropzone { flex-direction: column; text-align: center; }
}
