/* ============================================================
   원가 화면 — 휴대폰 전용 (컴퓨터에서 열어도 휴대폰 폭으로 가운데)
   색 · 크기는 디자인 시스템 이름(var(--kg-…))만 쓴다
   ============================================================ */
html, body { margin: 0; background: var(--kg-bg); color: var(--kg-ink); font-family: var(--kg-font); font-size: var(--kg-fs-base); }
body { -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
#app {
  max-width: 600px; margin: 0 auto; min-height: 100dvh;
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
}
#app[data-screen="login"] { padding-bottom: 0; }
.dim { color: var(--kg-ink-3); }
.grow { flex: 1; }
.loading-block { display: flex; align-items: center; justify-content: center; gap: var(--kg-space-3); padding: 30vh 0; color: var(--kg-ink-3); }
.preview-bar { padding: 4px var(--kg-space-4); background: var(--kg-warn-bg); color: var(--kg-warn); font-size: var(--kg-fs-2xs); font-weight: 700; text-align: center; }

/* ---------- 위 (화면 이름 · 사업장) ---------- */
.ab {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: var(--kg-space-3);
  height: calc(56px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) var(--kg-space-4) 0;
  background: var(--kg-bg);
}
.ab-title { margin: 0; font-size: var(--kg-fs-lg); font-weight: 800; letter-spacing: -.02em; }
.ab-back { display: inline-flex; align-items: center; gap: 2px; height: 44px; margin-left: -10px; padding: 0 10px 0 4px; border: 0; background: none; font-size: var(--kg-fs-base); font-weight: 600; cursor: pointer; }
.seg.biz { flex-wrap: nowrap; }
.seg.biz .seg-b { min-height: 34px; padding: 0 var(--kg-space-4); font-weight: 700; }
.biz-one { font-size: var(--kg-fs-sm); font-weight: 700; color: var(--kg-ink-2); }

/* ---------- 아래 탭 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  max-width: 600px; margin: 0 auto;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--kg-surface); border-top: 1px solid var(--kg-line);
}
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 60px; color: var(--kg-ink-3); font-size: var(--kg-fs-2xs); font-weight: 600; }
.tab[aria-current="page"] { color: var(--kg-ink); }
.tab[aria-current="page"] svg { stroke-width: 2.2; }
body.typing .tabbar { display: none; }   /* 자판이 올라오면 탭이 칸을 가리지 않게 */
body.typing #app { padding-bottom: var(--kg-space-8); }

/* ---------- 본문 ---------- */
.view { padding: 0 var(--kg-space-4) var(--kg-space-6); }
.sec { display: flex; align-items: center; justify-content: space-between; gap: var(--kg-space-2); min-height: 36px; margin: var(--kg-space-6) 2px var(--kg-space-3); font-size: var(--kg-fs-base); font-weight: 800; }
.sec-s { font-size: var(--kg-fs-xs); font-weight: 500; color: var(--kg-ink-3); }
.count { margin: var(--kg-space-3) 2px; font-size: var(--kg-fs-xs); color: var(--kg-ink-3); }

/* 검색 · 칩 (위에 붙어 있음) */
.sticky { position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 10; margin: 0 calc(-1 * var(--kg-space-4)); padding: var(--kg-space-3) var(--kg-space-4) 0; background: var(--kg-bg); }
.sticky:not(:has(.tabs-wrap)) { padding-bottom: var(--kg-space-1); }
.search { position: relative; display: flex; align-items: center; }
.search > svg { position: absolute; left: 14px; color: var(--kg-ink-3); pointer-events: none; }
.search input[type=search] { min-height: 46px; padding: 0 44px 0 42px; border-radius: var(--kg-radius-lg); background: var(--kg-surface); font-size: var(--kg-fs-base); }
.search input::-webkit-search-cancel-button { display: none; }
.q-clear { position: absolute; right: 6px; width: 36px; height: 36px; border: 0; background: transparent; border-radius: var(--kg-radius); color: var(--kg-ink-3); cursor: pointer; }

/* 분류 — 밑줄 탭 (디자인 시스템 .cat-tabs). 넘치면 옆으로 밀고, 양 끝 ‹ › (가려진 쪽에만) */
.tabs-wrap { position: relative; margin: var(--kg-space-1) calc(-1 * var(--kg-space-4)) 0; }
.tabs-wrap .cat-tabs { gap: var(--kg-space-1); padding: 0 var(--kg-space-4); scroll-behavior: smooth; }
.tabs-wrap .cat-tab { min-height: 46px; padding: 0 var(--kg-space-2); font-size: var(--kg-fs-sm); font-weight: 600; color: var(--kg-ink-3); }
.tabs-wrap .cat-tab[aria-selected="true"] { color: var(--kg-ink); font-weight: 800; border-bottom-color: var(--kg-ink); }
.tabs-arr {
  position: absolute; top: 0; bottom: 1px; z-index: 1; width: 40px;
  display: inline-flex; align-items: center; border: 0; color: var(--kg-ink-2); cursor: pointer;
}
.tabs-arr.is-prev { left: 0; justify-content: flex-start; padding-left: 6px; background: linear-gradient(to right, var(--kg-bg) 55%, transparent); }
.tabs-arr.is-next { right: 0; justify-content: flex-end; padding-right: 6px; background: linear-gradient(to left, var(--kg-bg) 55%, transparent); }
.tabs-arr[hidden] { display: none; }
/* 폼 안 분류 고르기 — 목록과 같은 한 줄 탭 + ‹ › (칸 바탕색에 맞춰 화살표 그라데이션) */
.field .tabs-wrap { margin-top: 0; }
.panel .tabs-arr.is-prev { background: linear-gradient(to right, var(--kg-surface) 55%, transparent); }
.panel .tabs-arr.is-next { background: linear-gradient(to left, var(--kg-surface) 55%, transparent); }
.panel.in-list .tabs-arr.is-prev { background: linear-gradient(to right, var(--kg-surface-2) 55%, transparent); }
.panel.in-list .tabs-arr.is-next { background: linear-gradient(to left, var(--kg-surface-2) 55%, transparent); }

/* 고르기 (폼 안 · 상태 거르기) — 상자형 토글. 칸이 모자라면 아래 줄로 (잘리지 않게) */
.seg.kg-seg {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 2px;
  width: 100%; overflow: visible; padding: 3px; border-radius: var(--kg-radius-lg);
}
.kg-seg .seg-b {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 var(--kg-space-2); border-radius: var(--kg-radius);
  font-size: var(--kg-fs-sm); line-height: 1.25; white-space: normal; word-break: keep-all; text-align: center;
}
.kg-seg .seg-b[aria-checked="true"] { color: var(--kg-ink); font-weight: 700; }
/* 개수 배지 — 구역 제목 옆(.cnt) · 상태 칸(.kg-seg .c) 모두 같은 모양 (흐린 회색 글자는 눈에 안 들어온다) */
.cnt, .kg-seg .c { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 20px; padding: 0 7px; border-radius: 999px; background: var(--kg-surface-3); color: var(--kg-ink); font-size: var(--kg-fs-xs); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.cnt { margin-left: 6px; vertical-align: 2px; }
.kg-seg .seg-b[aria-checked="true"] .c { background: var(--kg-ink); color: var(--kg-bg); }
.kg-seg .seg-b { gap: 4px; }
.view > div > .kg-seg.is-fill { margin-top: var(--kg-space-3); }

/* 개수 줄 — 왼쪽 개수 · 오른쪽 정렬 (모든 목록 같은 자리) */
.count-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--kg-space-2); min-height: 36px; margin: var(--kg-space-3) 0; }
.count-bar .count { margin: 0 2px; }
.sort { position: relative; flex: none; display: inline-flex; align-items: center; color: var(--kg-ink-2); }
.sort > svg { position: absolute; left: 10px; pointer-events: none; }
.sort select.sort-sel {
  width: auto; min-height: 34px; padding: 0 30px 0 30px;
  border: 1px solid var(--kg-line-2); border-radius: var(--kg-radius); background-color: var(--kg-surface);
  color: var(--kg-ink-2); font-size: var(--kg-fs-xs); font-weight: 700; cursor: pointer;
  background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%;
}
.sec-n { color: var(--kg-ink-3); font-weight: 700; }
.more-btn { display: block; width: 100%; min-height: 46px; margin-top: var(--kg-space-3); border: 1px solid var(--kg-line); border-radius: var(--kg-radius-lg); background: var(--kg-surface); color: var(--kg-ink-2); font-size: var(--kg-fs-sm); font-weight: 700; cursor: pointer; }
.more-btn:active { background: var(--kg-surface-2); }

/* 목록 */
.list { overflow: hidden; border: 1px solid var(--kg-line); border-radius: var(--kg-radius-lg); background: var(--kg-surface); }
.list > * + * { border-top: 1px solid var(--kg-line); }
.list-head { padding: 8px var(--kg-space-4); background: var(--kg-surface-2); color: var(--kg-ink-3); font-size: var(--kg-fs-xs); font-weight: 700; }
.list-empty { padding: var(--kg-space-6) var(--kg-space-4); color: var(--kg-ink-3); text-align: center; font-size: var(--kg-fs-sm); }
.list .empty { padding: var(--kg-space-10) var(--kg-space-4); }
.item { display: flex; align-items: center; gap: var(--kg-space-3); min-height: 68px; padding: var(--kg-space-3) var(--kg-space-4); }
.item:active, .rl-row:active, .pick:active, .impact-row:active { background: var(--kg-surface-2); }
.item-main { flex: 1; min-width: 0; }
.item-name { display: flex; align-items: center; gap: 6px; font-size: var(--kg-fs-base); font-weight: 700; line-height: 1.3; word-break: keep-all; }
.item-sub { margin-top: 3px; font-size: var(--kg-fs-xs); color: var(--kg-ink-3); font-variant-numeric: tabular-nums; }
.item-end { flex: none; text-align: right; }
.item-num { font-size: var(--kg-fs-md); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.item-st { display: block; margin-top: 1px; font-size: var(--kg-fs-2xs); font-weight: 700; }
.item-st.lbl { color: var(--kg-ink-3); font-weight: 500; }
.good { color: var(--kg-good); } .warn { color: var(--kg-warn); } .bad { color: var(--kg-bad); } .neutral { color: var(--kg-ink-3); }
.chip { min-height: 24px; font-size: var(--kg-fs-xs); font-weight: 700; white-space: nowrap; }
.chip.tiny { min-height: 18px; padding: 0 5px; font-size: var(--kg-fs-2xs); }

/* ---------- 요약 ---------- */
/* 평균 마진율 + 상태별 개수 — 한 카드 (제품 화면 위 카드와 같은 모양) */
.hero { margin-top: var(--kg-space-3); padding: var(--kg-space-4); border-radius: var(--kg-radius-lg); background: var(--kg-surface); border: 1px solid var(--kg-line); }
.hero-k { font-size: var(--kg-fs-sm); font-weight: 600; color: var(--kg-ink-2); }
.hero-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px var(--kg-space-3); margin-top: 2px; }
.hero-v { font-size: 40px; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.hero-s { font-size: var(--kg-fs-sm); color: var(--kg-ink-3); }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--kg-space-2); margin-top: var(--kg-space-3); }
.tile { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: var(--kg-space-3); border: 0; border-radius: var(--kg-radius); background: var(--kg-surface-2); text-align: left; cursor: pointer; }
.tile:active { background: var(--kg-surface-3); }
.tile:disabled { cursor: default; opacity: .55; }
.tile-l { order: -1; align-self: stretch; display: flex; align-items: center; justify-content: space-between; font-size: var(--kg-fs-xs); font-weight: 600; color: var(--kg-ink-3); }   /* 오른쪽 › = 누르면 목록으로 */
.item-name .cnt { margin-left: 0; }
.tile-n { font-size: var(--kg-fs-xl); font-weight: 800; font-variant-numeric: tabular-nums; }
.tile.neutral .tile-n { color: var(--kg-ink-2); }

/* ---------- 제품 한 개 ---------- */
.p-head { padding: var(--kg-space-3) 2px var(--kg-space-4); }   /* 헤더 아래 10px (모든 화면 같음) · 제목 아래 14px */
.p-cat { font-size: var(--kg-fs-xs); font-weight: 700; color: var(--kg-ink-3); }
.p-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 0; font-size: var(--kg-fs-lg); font-weight: 800; letter-spacing: -.02em; word-break: keep-all; }
.p-hero { padding: var(--kg-space-4); border: 1px solid var(--kg-line); border-radius: var(--kg-radius-lg); background: var(--kg-surface); }
.p-margin { display: flex; align-items: baseline; gap: var(--kg-space-3); }
.p-margin .k { font-size: var(--kg-fs-sm); font-weight: 600; color: var(--kg-ink-2); }
.p-margin .v { font-size: 40px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.p-margin .chip { align-self: center; }
.p-note { margin: var(--kg-space-2) 0 0; font-size: var(--kg-fs-sm); color: var(--kg-warn); font-weight: 600; }
.p-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--kg-space-2); margin-top: var(--kg-space-3); }
.p-stat { position: relative; display: flex; flex-direction: column; gap: 2px; padding: var(--kg-space-3); border: 1px solid transparent; border-radius: var(--kg-radius-lg); background: var(--kg-surface-2); text-align: left; }
.p-stat .k { font-size: var(--kg-fs-xs); color: var(--kg-ink-3); font-weight: 600; }
.p-stat .v { font-size: var(--kg-fs-md); font-weight: 800; font-variant-numeric: tabular-nums; }
.p-stat.is-edit { cursor: pointer; border-color: var(--kg-line-2); background: var(--kg-surface); }
.p-stat.is-active { border-color: var(--kg-brand); box-shadow: 0 0 0 2px var(--kg-brand-soft); }
.edit-hint { position: absolute; top: 10px; right: 10px; font-size: var(--kg-fs-2xs); font-weight: 700; color: var(--kg-ink-3); text-decoration: underline; text-underline-offset: 2px; }

/* 레시피 · 재료 줄 */
.rl-row { display: flex; align-items: center; gap: var(--kg-space-3); width: 100%; min-height: 62px; padding: var(--kg-space-3) var(--kg-space-3) var(--kg-space-3) var(--kg-space-4); border: 0; background: transparent; text-align: left; cursor: pointer; }
div.rl-row { cursor: default; }
.rl-main { flex: 1; min-width: 0; }
.rl-name { font-size: var(--kg-fs-sm); font-weight: 700; line-height: 1.35; word-break: keep-all; }
.rl-sub { margin-top: 2px; font-size: var(--kg-fs-xs); color: var(--kg-ink-3); font-variant-numeric: tabular-nums; }
.rl-end { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; min-width: 64px; }
.rl-cost { font-size: var(--kg-fs-sm); font-weight: 800; font-variant-numeric: tabular-nums; }
.rl-unit { font-size: var(--kg-fs-2xs); color: var(--kg-ink-3); }
.rl-bar { width: 56px; height: 4px; border-radius: 2px; background: var(--kg-chart-track); overflow: hidden; }
.rl-bar span { display: block; height: 100%; background: var(--kg-chart-ok); }
.rl-tog { flex: none; display: inline-flex; color: var(--kg-ink-3); }
.rline.is-open > .rl-row { background: var(--kg-surface-2); }

/* 펼친 칸 (그 자리에서 고치기) */
.panel { margin-top: var(--kg-space-3); padding: var(--kg-space-4); border: 1px solid var(--kg-brand); border-radius: var(--kg-radius-lg); background: var(--kg-surface); }
.panel.in-list { margin: 0; border: 0; border-top: 1px solid var(--kg-line); border-radius: 0; background: var(--kg-surface-2); }
.panel-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--kg-space-3); font-weight: 800; }
.panel-title .icon-btn { width: 40px; height: 40px; margin: -8px -8px -8px 0; border: 0; background: none; }
.num-in { display: block; margin-bottom: var(--kg-space-3); }
.num-lab { display: block; margin-bottom: 6px; font-size: var(--kg-fs-xs); font-weight: 700; color: var(--kg-ink-2); }
.num-box { position: relative; display: flex; align-items: center; }
.num-box input.num { min-height: 52px; padding-right: 48px; font-size: var(--kg-fs-lg); font-weight: 800; border-radius: var(--kg-radius-lg); }
.num-unit { position: absolute; right: 14px; font-size: var(--kg-fs-sm); font-weight: 700; color: var(--kg-ink-3); pointer-events: none; }
/* 칸 안 단위 고르기 (g ▾) — 매입 수량 칸에서 단위까지 */
.num-box.has-pick input.num { padding-right: 64px; }
.num-unit-pick { position: absolute; right: 4px; top: 4px; bottom: 4px; display: inline-flex; align-items: center; gap: 2px; padding: 0 10px; border-radius: var(--kg-radius); background: var(--kg-surface-2); color: var(--kg-ink-2); }
.num-unit-pick > svg { pointer-events: none; }
.num-unit-sel { appearance: none; -webkit-appearance: none; border: 0; background: transparent; color: inherit; font: inherit; font-size: var(--kg-fs-sm); font-weight: 800; padding: 0; min-height: 0; cursor: pointer; }
.num-unit-pick { cursor: pointer; }
.stepper { display: grid; grid-template-columns: 52px 1fr 52px; gap: var(--kg-space-2); }
.step { display: inline-flex; align-items: center; justify-content: center; min-height: 52px; border: 1px solid var(--kg-line-2); border-radius: var(--kg-radius-lg); background: var(--kg-surface); color: var(--kg-ink); cursor: pointer; }
.step:active { background: var(--kg-surface-3); }
.btn.is-busy { opacity: .6; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--kg-space-2); }
.pv-line { margin: 0 0 var(--kg-space-3); font-size: var(--kg-fs-sm); color: var(--kg-ink-2); font-variant-numeric: tabular-nums; }
.pv-line b { font-weight: 800; color: var(--kg-ink); }
.pv-line b.good { color: var(--kg-good); } .pv-line b.warn { color: var(--kg-warn); } .pv-line b.neutral { color: var(--kg-ink-3); }
.price-picks { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-bottom: var(--kg-space-3); }
.pp { display: flex; flex-direction: column; align-items: center; gap: 1px; min-height: 52px; padding: 6px 2px; border: 1px solid var(--kg-line-2); border-radius: var(--kg-radius); background: var(--kg-surface); cursor: pointer; }
.pp-k { font-size: var(--kg-fs-2xs); font-weight: 700; color: var(--kg-ink-3); }
.pp-v { font-size: var(--kg-fs-xs); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.pp.is-target { border-color: var(--kg-brand); }
.pp.is-target .pp-k { color: var(--kg-brand); }
.pp:active { background: var(--kg-surface-3); }
.pick-new { border-bottom: 0; }
.pick-new .pick-name { color: var(--kg-brand); }
.new-mat .field { margin-bottom: var(--kg-space-3); }
.new-mat input[type=text] { min-height: 48px; font-size: var(--kg-fs-base); border-radius: var(--kg-radius-lg); }
.form-err { margin: 0 0 var(--kg-space-3); color: var(--kg-bad); font-size: var(--kg-fs-sm); font-weight: 700; }
.item.as-btn { width: 100%; border: 0; border-top: 1px solid var(--kg-line); background: transparent; text-align: left; cursor: pointer; }
.list > .item.as-btn:first-child { border-top: 0; }
.panel-acts { display: flex; align-items: center; justify-content: flex-end; gap: var(--kg-space-2); }
.panel-acts .btn { min-width: 76px; }
.panel-acts .ask, .foot-acts .ask { flex: 1 1 100%; word-break: keep-all; font-size: var(--kg-fs-sm); font-weight: 700; color: var(--kg-bad); }
.panel-acts { flex-wrap: wrap; }
.foot-acts { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--kg-space-2); margin-top: var(--kg-space-6); }
.foot-date { margin-right: var(--kg-space-1); font-size: var(--kg-fs-xs); color: var(--kg-ink-3); font-variant-numeric: tabular-nums; }
/* 재료 화면 */
.p-margin .v.bad { color: var(--kg-bad); }
.m-note { margin: var(--kg-space-3) 0 0; font-size: var(--kg-fs-xs); color: var(--kg-ink-3); }
.panel.m-form { border-color: var(--kg-line); }   /* 재료 화면 고치는 칸 — 늘 펼쳐져 있어 다른 카드와 같은 테두리 */
.p-margin .k.dim { color: var(--kg-ink-3); }
.foot-acts .btn { min-width: 76px; }
.add-btn { margin-top: var(--kg-space-3); min-height: 50px; border-style: dashed; color: var(--kg-ink-2); }
.search.in-panel { margin-bottom: var(--kg-space-2); }
.search.in-panel input[type=search] { background: var(--kg-surface-2); }
.pick-list { max-height: 48vh; overflow-y: auto; margin: 0 calc(-1 * var(--kg-space-4)); border-top: 1px solid var(--kg-line); }
.pick { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; min-height: 56px; padding: var(--kg-space-2) var(--kg-space-4); border: 0; border-bottom: 1px solid var(--kg-line); background: transparent; text-align: left; cursor: pointer; }
.pick-name { display: flex; align-items: center; gap: 6px; font-size: var(--kg-fs-sm); font-weight: 700; }
.pick-sub { font-size: var(--kg-fs-xs); color: var(--kg-ink-3); }
.picked { display: flex; align-items: center; justify-content: space-between; gap: var(--kg-space-3); margin-bottom: var(--kg-space-3); padding: var(--kg-space-3); border-radius: var(--kg-radius-lg); background: var(--kg-surface-2); }

/* 재료 → 쓰는 제품 */
.impact { margin-top: var(--kg-space-4); }
.impact-h { margin-bottom: 4px; font-size: var(--kg-fs-xs); font-weight: 700; color: var(--kg-ink-3); }
.impact-row { display: flex; align-items: center; justify-content: space-between; gap: var(--kg-space-3); min-height: 44px; padding: 0 2px; border-top: 1px solid var(--kg-line); font-size: var(--kg-fs-sm); }
.impact-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.impact-v { flex: none; font-variant-numeric: tabular-nums; }
.m-spec { margin-bottom: var(--kg-space-3); font-size: var(--kg-fs-xs); color: var(--kg-ink-3); }
.m-edit .field { margin-bottom: var(--kg-space-3); }
.m-edit input[type=text] { min-height: 48px; font-size: var(--kg-fs-base); border-radius: var(--kg-radius-lg); }
.m-edit .panel-acts { margin-bottom: var(--kg-space-2); }

/* 재료 → 쓰는 제품 (누르면 사용량 고치기 · 빼기) */
.use { border-top: 1px solid var(--kg-line); }
.use-row { display: flex; align-items: center; gap: var(--kg-space-2); width: 100%; min-height: 52px; padding: 6px 2px; border: 0; background: none; text-align: left; font-size: var(--kg-fs-sm); cursor: pointer; }
div.use-row { cursor: default; }
.use-row:active { background: var(--kg-surface-3); }
.use-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.use-q { font-size: var(--kg-fs-xs); color: var(--kg-ink-3); font-variant-numeric: tabular-nums; }
.use-panel { margin: 0 0 var(--kg-space-3); padding: var(--kg-space-3); border: 1px solid var(--kg-brand); border-radius: var(--kg-radius-lg); background: var(--kg-surface); }
.use-panel .panel-title { margin-bottom: var(--kg-space-2); }
.use-panel .pick-list { margin: 0 calc(-1 * var(--kg-space-3)); max-height: 40vh; }
.sm-add { min-height: 46px; margin-top: var(--kg-space-2); }

/* ---------- 더보기 ---------- */
.card.me { margin-top: var(--kg-space-3); padding: var(--kg-space-4); border: 1px solid var(--kg-line); border-radius: var(--kg-radius-lg); background: var(--kg-surface); }
.me-name { font-size: var(--kg-fs-md); font-weight: 800; }
.me-sub { margin-top: 2px; font-size: var(--kg-fs-sm); color: var(--kg-ink-3); }
.set-list { margin-top: var(--kg-space-3); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: var(--kg-space-3); min-height: 60px; padding: var(--kg-space-2) var(--kg-space-4); }
.set-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.set-k { font-weight: 700; }
.set-sub { font-size: var(--kg-fs-xs); color: var(--kg-ink-3); font-variant-numeric: tabular-nums; }
.set-row .seg-b { min-height: 34px; padding: 0 var(--kg-space-4); }
.set-gap { height: var(--kg-space-3); }

/* ---------- 로그인 ---------- */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100dvh; padding: var(--kg-space-6) var(--kg-space-5); }
.login { width: 100%; max-width: 360px; }
.login-brand { margin-bottom: var(--kg-space-8); text-align: center; }
.logo-word { display: block; font-family: var(--kg-font-brand); font-size: var(--kg-fs-sm); font-weight: 700; letter-spacing: .14em; color: var(--kg-logo); }
.login-brand h1 { margin: 6px 0 0; font-size: var(--kg-fs-2xl); font-weight: 800; letter-spacing: -.02em; }
.login input { min-height: 52px; font-size: var(--kg-fs-base); border-radius: var(--kg-radius-lg); }
.login .btn.lg { min-height: 54px; margin-top: var(--kg-space-2); font-size: var(--kg-fs-md); }
.login .btn.plain { margin-top: var(--kg-space-2); }
.login .auth-err { margin: 0 0 var(--kg-space-2); text-align: left; }

/* 알림 — 아래 탭 위 */
#toasts { position: fixed; left: 0; right: 0; transform: none; width: auto; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 50; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 var(--kg-space-4); pointer-events: none; }
body.typing #toasts { bottom: var(--kg-space-4); }

/* 제품 화면 ‹ 이전 · 다음 › — 아래 탭 바로 위에 딱 붙여 고정. 상자 없이 화면 바탕색 (탭과 사이로 목록이 비치지 않게)
   본문 맨 아래는 이 줄 높이만큼 더 띄워 마지막 칸이 가려지지 않게 */
.pn-foot {
  position: fixed; left: 0; right: 0; bottom: calc(61px + env(safe-area-inset-bottom)); z-index: 25;
  display: flex; align-items: center; justify-content: space-between; gap: var(--kg-space-2);
  max-width: 600px; margin: 0 auto; padding: 4px var(--kg-space-2);
  background: var(--kg-bg);
}
.view:has(> .pn-foot) { padding-bottom: calc(var(--kg-space-6) + 52px); }
body.typing .pn-foot { display: none; }
.pn-go { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 var(--kg-space-4) 0 var(--kg-space-2); border-radius: var(--kg-radius); font-size: var(--kg-fs-sm); font-weight: 700; }
.pn-go.is-next { padding: 0 var(--kg-space-2) 0 var(--kg-space-4); }
.pn-go:active { background: var(--kg-surface-2); }
.pn-go.is-off { color: var(--kg-ink-3); opacity: .45; pointer-events: none; }
.pn-at { font-size: var(--kg-fs-xs); font-weight: 700; color: var(--kg-ink-3); font-variant-numeric: tabular-nums; }

/* 검색칸 + 추가 (목록 도구줄: 검색칸 → 주 동작 버튼 맨 오른쪽) */
.search-row { display: flex; align-items: center; gap: var(--kg-space-2); }
.search-row .search { flex: 1; min-width: 0; }
.search-add { flex: none; min-height: 46px; min-width: 64px; border-radius: var(--kg-radius-lg); }
.panel.top-add { margin: var(--kg-space-3) 0; }

/* 재료 추가 칸 — 묶음 탭 (검색 중에는 흐리게: 전체에서 찾는다) */
.pick-groups .tabs-wrap { margin-top: 0; }
.pick-groups .tabs-arr { background: none; }
.pick-groups .cat-tab { min-height: 42px; }
.pick-groups.is-off { opacity: .4; pointer-events: none; }
.pick-groups + .pick-list { border-top: 0; }

/* 요약 — 목표 마진율 바꿔 보기 */
.tiles.two-col { grid-template-columns: repeat(2, 1fr); }
.tile.is-static { cursor: default; }
.sim-note { margin: var(--kg-space-3) 2px 0; font-size: var(--kg-fs-xs); color: var(--kg-ink-3); }
.sim-cats { display: grid; gap: 6px; margin-top: var(--kg-space-3); }
.sim-cat { display: flex; justify-content: space-between; font-size: var(--kg-fs-sm); color: var(--kg-ink-2); }
.sim-cat b { color: var(--kg-warn); font-variant-numeric: tabular-nums; }

/* 둥근 차트 — 요약 "목표 마진율 바꿔 보기" (그 목표에서 양호 비율) */
.donut { position: relative; flex: none; display: inline-grid; place-items: center; }
.donut .dn-bg { stroke: var(--kg-surface-3); }
.donut .dn-fg { stroke: var(--kg-ink-3); transition: stroke-dasharray .25s ease; }
.donut.good .dn-fg { stroke: var(--kg-good); }
.donut.warn .dn-fg { stroke: var(--kg-warn); }
.dn-c { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.dn-k { font-size: var(--kg-fs-2xs); font-weight: 600; color: var(--kg-ink-3); }
.dn-v { font-size: var(--kg-fs-lg); font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.donut.good .dn-v { color: var(--kg-good); }
.donut.warn .dn-v { color: var(--kg-warn); }

/* 차트 | 양호 · 점검 · 계산된 제품 */
.p-top { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: var(--kg-space-4); }
.p-kv { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kv { display: flex; align-items: baseline; justify-content: space-between; gap: var(--kg-space-2); min-height: 32px; padding: 4px 0; border: 0; background: none; text-align: left; font-variant-numeric: tabular-nums; }
.kv .k { font-size: var(--kg-fs-xs); font-weight: 600; color: var(--kg-ink-3); }
.kv .v { font-size: var(--kg-fs-base); font-weight: 800; }
.kv.is-main .v { font-size: var(--kg-fs-md); }

/* 목표 마진율 막대 */
.sim { margin-top: var(--kg-space-4); padding: var(--kg-space-3) var(--kg-space-4); border-radius: var(--kg-radius-lg); background: var(--kg-surface-2); }
.sim-h { display: flex; align-items: baseline; justify-content: space-between; font-size: var(--kg-fs-xs); font-weight: 700; color: var(--kg-ink-2); }
.sim-v { font-size: var(--kg-fs-md); color: var(--kg-ink); font-variant-numeric: tabular-nums; }
.sim-range { width: 100%; margin: var(--kg-space-3) 0 2px; accent-color: var(--kg-brand); min-height: 28px; }
.sim-mm { display: flex; justify-content: space-between; font-size: var(--kg-fs-2xs); color: var(--kg-ink-3); font-variant-numeric: tabular-nums; }
@media (max-width: 360px) { .p-top { grid-template-columns: 1fr; justify-items: center; } .p-kv { width: 100%; } }
.sim.in-card { margin-top: 0; margin-bottom: var(--kg-space-3); }
.kv.good .v { color: var(--kg-good); }
.kv.warn .v { color: var(--kg-warn); }
/* 제품 화면 — 판매가 줄 누르면 고치기, 시뮬레이션 막대 아래 되돌리기 · 저장 */
button.kv.is-edit { cursor: pointer; }
.sim-acts { display: flex; justify-content: flex-end; gap: var(--kg-space-2); }
.sim-acts:not(:empty) { margin-top: var(--kg-space-3); }
