/* Layout: 택배 상자. 크라프트지 바탕 위에 흰 운송장 라벨(입력/결과)과 포장 테이프 띠.
   도구 페이지는 왼쪽 입력 라벨 + 오른쪽 결과(또는 A4 문서 미리보기). 강조는 '취급주의' 주황. */
:root {
  --kraft: #D8C09A;
  --kraft-bg: #E9DCC2;
  --kraft-dark: #9C7B50;
  --label: #FFFDF8;
  --ink: #1C1A17;
  --ink-2: #4A443B;
  --muted: #776E61;
  --line: #E1D6C2;
  --tape: rgba(214, 186, 120, .55);
  --accent: #DE5A1F;
  --good: #2B7A4B;
  --bad: #C2372B;
  --shadow: 0 1px 0 rgba(255,255,255,.5) inset, 0 14px 30px -20px rgba(60,40,10,.45);
  --f-display: "Black Han Sans", "Noto Sans KR", sans-serif;
  --f-body: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --f-serif: "Nanum Myeongjo", "Batang", serif;
  --t--1: clamp(.8rem, .78rem + .1vw, .86rem);
  --t-0: clamp(.95rem, .92rem + .15vw, 1.02rem);
  --t-1: clamp(1.12rem, 1.05rem + .3vw, 1.3rem);
  --t-2: clamp(1.4rem, 1.25rem + .75vw, 1.9rem);
  --t-3: clamp(1.9rem, 1.5rem + 1.8vw, 3rem);
  --t-4: clamp(2.3rem, 1.6rem + 3.4vw, 4.4rem);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --kraft: #4E412F; --kraft-bg: #1D1914; --kraft-dark: #8C7350; --label: #27221C; --ink: #EFE8DC; --ink-2: #CFC5B5; --muted: #A29684; --line: #3B342A; --tape: rgba(140,118,70,.45); --accent: #F27A43; --good: #5CC08A; --bad: #F06B5E; --shadow: 0 14px 30px -20px rgba(0,0,0,.8); color-scheme: dark; }
}
:root[data-theme="dark"] { --kraft: #4E412F; --kraft-bg: #1D1914; --kraft-dark: #8C7350; --label: #27221C; --ink: #EFE8DC; --ink-2: #CFC5B5; --muted: #A29684; --line: #3B342A; --tape: rgba(140,118,70,.45); --accent: #F27A43; --good: #5CC08A; --bad: #F06B5E; --shadow: 0 14px 30px -20px rgba(0,0,0,.8); color-scheme: dark; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; color: var(--ink); font-family: var(--f-body); font-size: var(--t-0); line-height: 1.65;
  word-break: keep-all; overflow-wrap: anywhere; overflow-x: hidden; -webkit-font-smoothing: antialiased;
  background: var(--kraft-bg);
  background-image: repeating-linear-gradient(93deg, rgba(120, 90, 40, .045) 0 2px, transparent 2px 9px), repeating-linear-gradient(-4deg, rgba(255,255,255,.05) 0 1px, transparent 1px 12px);
}
a { color: inherit; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding-inline: 20px; }
.num { font-variant-numeric: tabular-nums; }

/* 헤더: 포장 테이프 띠 */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--kraft); border-bottom: 2px solid var(--kraft-dark); }
.top::after { content: ""; position: absolute; left: 0; right: 0; bottom: -10px; height: 8px; background: linear-gradient(var(--tape), var(--tape)); pointer-events: none; }
.top__in { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 10px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo__box { width: 30px; height: 26px; background: var(--kraft-dark); position: relative; border-radius: 2px; }
.logo__box::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 8px; background: rgba(255,255,255,.25); }
.logo__box::after { content: ""; position: absolute; left: 12px; top: 0; bottom: 0; width: 6px; background: var(--tape); }
.logo b { font-family: var(--f-display); font-weight: 400; font-size: 1.35rem; letter-spacing: .01em; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; }
.nav a { text-decoration: none; font-size: var(--t--1); padding: 6px 10px; border-radius: 4px; color: var(--ink-2); }
.nav a:hover, .nav a[aria-current="page"] { background: var(--label); color: var(--ink); }

/* 라벨(운송장) */
.label { background: var(--label); border-radius: 4px; box-shadow: var(--shadow); position: relative; padding: clamp(16px, 2.6vw, 24px); min-width: 0; }
.label--tape::before { content: ""; position: absolute; top: -10px; left: 50%; width: 90px; height: 22px; transform: translateX(-50%) rotate(-2deg); background: var(--tape); }
.label__head { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 2px solid var(--ink); padding-bottom: 8px; margin-bottom: 14px; }
.label__head h2, .label__head h3 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: var(--t-1); letter-spacing: .01em; }
.barcode { height: 26px; width: 120px; background: repeating-linear-gradient(90deg, var(--ink) 0 2px, transparent 2px 4px, var(--ink) 4px 5px, transparent 5px 8px, var(--ink) 8px 11px, transparent 11px 12px); opacity: .85; flex: none; }
.stamp { display: inline-block; border: 2.5px solid var(--accent); color: var(--accent); font-family: var(--f-display); padding: 2px 10px; transform: rotate(-4deg); border-radius: 3px; font-size: .9rem; letter-spacing: .05em; }

/* 히어로 */
.hero { padding-block: clamp(32px, 5vw, 64px) clamp(20px, 3vw, 36px); display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: clamp(20px, 4vw, 56px); align-items: center; }
.hero h1 { font-family: var(--f-display); font-weight: 400; font-size: var(--t-4); line-height: 1.12; margin: 10px 0 14px; letter-spacing: -.01em; text-wrap: balance; }
.hero p { margin: 0 0 20px; color: var(--ink-2); max-width: 34em; }
.page-head { padding-block: clamp(24px, 4vw, 44px) 18px; }
.page-head h1 { font-family: var(--f-display); font-weight: 400; font-size: var(--t-3); margin: 8px 0 6px; letter-spacing: -.01em; }
.page-head p { margin: 0; color: var(--ink-2); max-width: 46em; }

/* 도구 카드 목록 */
.tools { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; padding-block: 12px 40px; }
.tool { text-decoration: none; display: grid; gap: 6px; align-content: start; transition: transform .15s ease; }
.tool:hover { transform: translateY(-3px); }
.tool h3 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: var(--t-2); }
.tool p { margin: 0; color: var(--muted); font-size: var(--t--1); }
.tool .go { margin-top: 8px; font-weight: 700; color: var(--accent); font-size: var(--t--1); }

/* 작업대: 입력 + 결과 */
.bench { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 22px; align-items: start; padding-bottom: 40px; }
.bench__form { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow: auto; }
.fs { border: 0; margin: 0 0 14px; padding: 0; display: grid; gap: 10px; }
.fs legend { font-weight: 700; font-size: var(--t--1); padding: 0; margin-bottom: 6px; color: var(--ink); display: flex; gap: 6px; align-items: center; }
.fs legend::before { content: ""; width: 10px; height: 10px; background: var(--accent); border-radius: 2px; }
.f { display: grid; gap: 3px; min-width: 0; }
.f > span { font-size: .78rem; color: var(--muted); font-weight: 500; }
.f input, .f select, .f textarea { width: 100%; min-width: 0; border: 1px solid var(--line); background: var(--kraft-bg); border-radius: 4px; padding: 8px 10px; }
.f input:focus, .f select:focus, .f textarea:focus { outline: none; border-color: var(--accent); background: var(--label); }
.f textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
.f .unit { position: relative; }
.f .unit input { padding-right: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.f .unit::after { content: attr(data-u); position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .82rem; }
.g2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.g3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.chk { display: flex; gap: 8px; align-items: center; font-size: var(--t--1); }
.chk input { accent-color: var(--accent); width: 16px; height: 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 2px solid var(--ink); background: var(--label); color: var(--ink); padding: 9px 16px; border-radius: 4px; font-weight: 700; cursor: pointer; text-decoration: none; font-size: var(--t--1); }
.btn:hover { background: var(--kraft-bg); }
.btn--go { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--go:hover { filter: brightness(.95); background: var(--accent); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.hint { font-size: .76rem; color: var(--muted); margin: 0; }

/* 마진 결과 */
.duo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.ch__name { display: flex; align-items: center; gap: 8px; }
.ch__dot { width: 12px; height: 12px; border-radius: 50%; }
.big-profit { font-family: var(--f-display); font-weight: 400; font-size: var(--t-3); line-height: 1; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.big-profit.good { color: var(--good); } .big-profit.bad { color: var(--bad); }
.rate { font-weight: 700; }
.rows { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 0; font-size: var(--t--1); }
.rows li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.rows li span:last-child { font-variant-numeric: tabular-nums; font-weight: 500; white-space: nowrap; }
.rows li.minus span:last-child { color: var(--bad); }
.rows li.total { border-bottom: 2px solid var(--ink); font-weight: 700; }
.rows li small { color: var(--muted); }
.target { margin-top: 14px; padding: 10px 12px; background: var(--kraft-bg); border-radius: 4px; font-size: var(--t--1); }
.target b { font-variant-numeric: tabular-nums; }
.sens { width: 100%; border-collapse: collapse; font-size: var(--t--1); font-variant-numeric: tabular-nums; min-width: 420px; }
.sens th, .sens td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: right; }
.sens th:first-child, .sens td:first-child { text-align: left; }
.sens thead th { color: var(--muted); font-weight: 500; font-size: .76rem; }
.sens tr.cur td { background: var(--kraft-bg); font-weight: 700; }
.sens .good { color: var(--good); } .sens .bad { color: var(--bad); }
.scroll-x { overflow-x: auto; }

/* A4 문서 미리보기 (견적서·거래명세서·급여명세서·메뉴판) */
.doc-wrap { overflow-x: auto; padding: 4px; }
.doc { width: 210mm; min-height: 297mm; max-width: none; margin: 0 auto; background: #fff; color: #111; box-shadow: var(--shadow); padding: 16mm 14mm; font-family: var(--f-body); font-size: 10pt; line-height: 1.5; position: relative; }
.doc--land { width: 297mm; min-height: 210mm; }
.doc h1.doc-title { font-family: var(--f-serif); font-size: 26pt; letter-spacing: .6em; text-align: center; margin: 0 0 6mm; padding-left: .6em; font-weight: 800; }
.doc table { width: 100%; border-collapse: collapse; }
.doc th, .doc td { border: 1px solid #333; padding: 1.6mm 2mm; vertical-align: middle; }
.doc th { background: #f2f2f2; font-weight: 700; white-space: nowrap; }
.doc .r { text-align: right; font-variant-numeric: tabular-nums; }
.doc .c { text-align: center; }
.doc .amount-words { font-size: 12pt; font-weight: 700; }
.doc .seal-box { position: relative; display: inline-block; }
.doc .seal-img { position: absolute; right: -6mm; top: 50%; transform: translateY(-50%); width: 16mm; height: 16mm; object-fit: contain; mix-blend-mode: multiply; opacity: .9; }
.doc .muted { color: #666; }
.doc .note { margin-top: 5mm; border: 1px solid #333; padding: 3mm; min-height: 18mm; white-space: pre-wrap; }
.doc-zoom { transform-origin: top center; }

/* 거래명세서: 공급자 보관용(빨강) / 공급받는자 보관용(파랑) */
.stmt { height: 132mm; padding: 6mm 0; border-bottom: 1px dashed #999; }
.stmt:last-child { border-bottom: 0; }
.stmt h2 { font-family: var(--f-serif); font-size: 18pt; letter-spacing: .4em; text-align: center; margin: 0 0 3mm; }
.stmt h2 small { font-size: 9pt; letter-spacing: 0; font-family: var(--f-body); font-weight: 400; }
.stmt.red th, .stmt.red td, .stmt.red h2 { border-color: #C4302B; color: #C4302B; }
.stmt.red td { color: #111; }
.stmt.red th { background: #FCEDEC; }
.stmt.blue th, .stmt.blue td, .stmt.blue h2 { border-color: #2B57B8; color: #2B57B8; }
.stmt.blue td { color: #111; }
.stmt.blue th { background: #ECF1FC; }
.stmt table { font-size: 8.5pt; }
.stmt th, .stmt td { padding: 1mm 1.5mm; }

/* 품목 입력 표 */
.items { display: grid; gap: 6px; }
.item-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) 64px minmax(0, 1.2fr) 30px; gap: 6px; align-items: center; }
.item-row input { width: 100%; min-width: 0; border: 1px solid var(--line); background: var(--kraft-bg); border-radius: 4px; padding: 6px 8px; font-size: .86rem; }
.item-row input.n { text-align: right; font-variant-numeric: tabular-nums; }
.item-row button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1.1rem; }
.item-head { font-size: .72rem; color: var(--muted); }

/* 메뉴판 템플릿 */
.menu-doc { font-family: var(--f-body); }
.menu-doc.t-bunsik { background: #FFF6D6; color: #1a1a1a; }
.menu-doc.t-bunsik .m-title { font-family: var(--f-display); font-size: 44pt; color: #D7262B; text-align: center; margin: 0; line-height: 1.1; }
.menu-doc.t-bunsik .m-sub { text-align: center; font-weight: 700; margin: 2mm 0 8mm; }
.menu-doc.t-bunsik .m-cat { font-family: var(--f-display); font-size: 20pt; background: #D7262B; color: #FFF6D6; display: inline-block; padding: 1mm 5mm; margin: 6mm 0 3mm; }
.menu-doc.t-bunsik .m-item { display: flex; align-items: baseline; gap: 3mm; font-size: 15pt; font-weight: 700; padding: 1.6mm 0; border-bottom: 2px dotted #c9a33a; }
.menu-doc.t-bunsik .m-item .p { color: #D7262B; font-family: var(--f-display); font-weight: 400; font-size: 18pt; }
.menu-doc.t-cafe { background: #fff; color: #222; }
.menu-doc.t-cafe .m-title { font-family: var(--f-serif); font-size: 34pt; letter-spacing: .25em; text-align: center; margin: 6mm 0 0; font-weight: 800; }
.menu-doc.t-cafe .m-sub { text-align: center; color: #777; letter-spacing: .2em; font-size: 9pt; margin: 2mm 0 12mm; }
.menu-doc.t-cafe .m-cat { font-family: var(--f-serif); font-size: 15pt; letter-spacing: .3em; border-bottom: 1px solid #222; padding-bottom: 1.5mm; margin: 8mm 0 3mm; }
.menu-doc.t-cafe .m-item { display: flex; align-items: baseline; gap: 3mm; font-size: 12pt; padding: 1.8mm 0; }
.menu-doc.t-cafe .m-item .p { font-variant-numeric: tabular-nums; }
.menu-doc.t-chalk { background: #23382E; color: #F4F1E6; }
.menu-doc.t-chalk .m-title { font-family: "Nanum Pen Script", cursive; font-size: 58pt; text-align: center; margin: 0; line-height: 1; }
.menu-doc.t-chalk .m-sub { text-align: center; font-family: "Nanum Pen Script", cursive; font-size: 20pt; margin: 0 0 6mm; color: #E9D8A6; }
.menu-doc.t-chalk .m-cat { font-family: "Nanum Pen Script", cursive; font-size: 32pt; color: #E9D8A6; margin: 6mm 0 1mm; border-bottom: 2px dashed rgba(244,241,230,.4); }
.menu-doc.t-chalk .m-item { display: flex; align-items: baseline; gap: 3mm; font-family: "Nanum Pen Script", cursive; font-size: 24pt; padding: .6mm 0; }
.m-item .n { flex: none; }
.m-item .dots { flex: 1; border-bottom: 1px dotted currentColor; opacity: .35; transform: translateY(-1.5mm); }
.m-item .p { flex: none; }
.m-item small { display: block; font-size: .62em; opacity: .7; font-weight: 400; font-family: var(--f-body); }
.m-cols { columns: 2; column-gap: 12mm; }
.m-cols .m-block { break-inside: avoid; }
.tags { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 64mm; gap: 4mm; }
.tag { border: 2px solid #111; border-radius: 3mm; padding: 5mm; display: grid; align-content: space-between; position: relative; overflow: hidden; }
.tag .tn { font-size: 18pt; font-weight: 900; line-height: 1.2; }
.tag .td { font-size: 9pt; color: #555; }
.tag .tp { font-family: var(--f-display); font-size: 40pt; text-align: right; line-height: 1; }
.tag .tp small { font-size: 14pt; }
.tag .tbar { position: absolute; left: 0; top: 0; bottom: 0; width: 6mm; background: #DE5A1F; }
.tag.sale .tp { color: #C4302B; }
.tag .was { font-size: 11pt; text-decoration: line-through; color: #888; text-align: right; }

/* 설명 섹션 */
.guide { padding-block: 10px 48px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.guide h3 { margin: 0 0 6px; font-size: var(--t-0); }
.guide p { margin: 0; color: var(--muted); font-size: var(--t--1); }
.faq dt { font-weight: 700; margin-top: 12px; }
.faq dd { margin: 4px 0 0; color: var(--muted); font-size: var(--t--1); }
.foot { padding-block: 26px 40px; color: var(--muted); font-size: var(--t--1); border-top: 2px solid var(--kraft-dark); }
.foot__in { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

@media (max-width: 980px) {
  .hero, .bench { grid-template-columns: minmax(0, 1fr); }
  .bench__form { position: static; max-height: none; }
  .tools, .guide { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .nav { display: none; }
  .tools, .guide, .duo { grid-template-columns: minmax(0, 1fr); }
  .g3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .item-row { grid-template-columns: minmax(0, 1.6fr) 54px minmax(0, 1fr) 26px; }
  .item-row .spec { display: none; }
}

@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  body > header, body > footer, .no-print, .bench__form, .page-head, .guide, .hero, .tools { display: none !important; }
  .bench { display: block; padding: 0; }
  .doc-wrap { overflow: visible; padding: 0; }
  .doc { box-shadow: none; margin: 0; transform: none !important; }
  .doc-zoom { transform: none !important; }
  .label { box-shadow: none; }
}
