/* ============================================================
   그룹웨어 기본 — 글자 · 제목 · 링크, 그룹웨어만 쓰는 조각 (차트 · 모달 · 원가 표 …)
   공통 부품(버튼 · 입력 · 카드 · 탭 …)은 디자인 시스템 kg-components.css 에 있다
   ============================================================ */

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; line-height: var(--lh-tight); font-weight: 700; }
h1 { font-size: var(--fs-lg); }
h2 { font-size: var(--fs-md); }
h3 { font-size: var(--fs-base); }
p  { margin: 0; }

a { color: var(--point); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   차트 (core/ui/charts.js) — 얇은 막대, 끝만 둥글게, 목표선, 값은 글자색
   ============================================================ */
.ch-legend { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); font-size: var(--fs-xs); color: var(--ink-2); }
.ch-key { display: inline-flex; align-items: center; gap: 6px; }
.ch-key i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.ch-key i.tick { width: 2px; height: 12px; border-radius: 1px; background: var(--ink); }

.ch-bars .ch-legend { margin-bottom: var(--s-3); }
.ch-rows { display: flex; flex-direction: column; }
.ch-row, .ch-axis {
  display: grid; grid-template-columns: minmax(96px, 30%) 1fr; gap: var(--s-3); align-items: center;
}
.ch-row {
  width: 100%; min-height: 34px; padding: 3px var(--s-2);
  border: 0; border-radius: var(--r-sm); background: transparent;
  font: inherit; color: var(--ink); text-align: left; cursor: pointer;
}
.ch-row:hover, .ch-row:focus-visible { background: var(--surface-2); outline: none; }
.ch-row:focus-visible { box-shadow: inset 0 0 0 2px var(--point); }
.ch-name { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.ch-name .n { font-size: var(--fs-sm); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-name .s { font-size: var(--fs-2xs); color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-plot { display: flex; align-items: center; gap: var(--s-2); min-width: 0; position: relative; }
.ch-track { position: relative; flex: 1; height: 14px; }
.ch-bar {
  position: absolute; left: 0; top: 0; bottom: 0;
  border-radius: 0 4px 4px 0;            /* 둥근 쪽은 값 끝, 바닥 쪽은 각지게 */
  transition: filter .12s;
}
.ch-row:hover .ch-bar, .ch-row:focus-visible .ch-bar { filter: brightness(1.12); }
.ch-tick { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--ink); opacity: .75; }
.ch-val { flex: none; min-width: 64px; font-size: var(--fs-xs); font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; display: inline-flex; gap: 4px; align-items: center; }
.ch-flag { flex: none; white-space: nowrap; font-size: var(--fs-2xs); font-weight: 700; padding: 1px 5px; border-radius: 4px; background: var(--warn-bg); color: var(--warn); }
.ch-axis { padding: 0 var(--s-2); margin-top: 2px; }
.ch-axis .ch-plot { padding-right: 72px; }
.ch-ticks { position: relative; flex: 1; height: 16px; border-top: 1px solid var(--line); }
.ch-ticks span { position: absolute; top: 3px; transform: translateX(-50%); font-size: var(--fs-2xs); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.ch-ticks span:first-child { transform: none; }
.ch-ticks span:last-child { transform: translateX(-100%); }
.ch-table { margin-top: var(--s-4); }
.ch-table summary { cursor: pointer; font-size: var(--fs-xs); color: var(--ink-2); }
.ch-table .table-wrap { margin-top: var(--s-2); }

.ch-tip {
  position: fixed; z-index: 300; pointer-events: none;
  min-width: 160px; padding: var(--s-2) var(--s-3);
  border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--surface); box-shadow: var(--shadow-3);
  font-size: var(--fs-xs);
}
.ch-tip-row { display: flex; justify-content: space-between; gap: var(--s-4); padding: 1px 0; }
.ch-tip-row .v { order: 2; font-variant-numeric: tabular-nums; color: var(--ink); }
.ch-tip-row .k { color: var(--ink-3); }
.ch-tip-row.strong .v { font-weight: 800; font-size: var(--fs-sm); }
.ch-tip-row.strong .k { color: var(--ink); font-weight: 600; }

.ch-split { display: flex; flex-direction: column; gap: var(--s-2); }
.ch-split-bar { display: flex; gap: 2px; height: 14px; }
.ch-split-bar .ch-seg:first-child { border-radius: 4px 0 0 4px; }
.ch-split-bar .ch-seg:last-child { border-radius: 0 4px 4px 0; }
.ch-split-bar .ch-seg:only-child { border-radius: 4px; }

.ch-mini { display: inline-block; width: 72px; vertical-align: middle; }
.ch-mini .ch-track { display: block; height: 8px; background: var(--chart-track); border-radius: 4px; }
.ch-mini .ch-bar { border-radius: 4px; }
.ch-mini .ch-tick { top: -3px; bottom: -3px; }
.ch-rows.ch-collapsed .ch-more { display: none; }

/* 대시보드 "확인 필요" 개수 — 오류가 아니라 할 일이라 주황 톤 (급한 신고 기한만 빨강) */
.todo-count {
  flex: none; height: 30px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-full);
  background: var(--warn-bg); color: var(--warn);
  font-size: var(--fs-sm); font-weight: 700; font-variant-numeric: tabular-nums;
}
.todo-count.bad { background: var(--bad-bg); color: var(--bad); }

/* ---------- 원가 현황 — 목표 마진율별 판매가를 표에서 바로 ---------- */
table.cost-tbl th.cost-group { text-align: center; border-left: 1px solid var(--line-2); color: var(--ink); }
table.cost-tbl th.cost-target { text-align: right; width: 92px; }
table.cost-tbl th.cost-target:first-child,
table.cost-tbl td:nth-last-child(4) { border-left: 1px solid var(--line); }
table.cost-tbl td.cost-mine { background: var(--point-soft); }
