/* ==========================================================================
   wprofitcc — 수익률 계산기 디자인 시스템
   중립 회색 바탕 + 단일 강조색(인디고), 결과값은 의미색(초록/빨강)만 사용
   ========================================================================== */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #f1f3f6;
  --hover: #f3f6fd;
  --zebra: #fbfbfc;
  --text: #111827;
  --text-2: #4b5563;
  --text-3: #9ca3af;
  --line: #e5e7eb;
  --line-soft: #eef0f3;
  --line-2: #cfd4dc;
  --accent: #3b5bdb;
  --accent-hover: #2f4bc4;
  --accent-soft: #eef2ff;
  --accent-line: #c7d2fe;
  --pos: #15803d;
  --pos-soft: #ecfdf3;
  --neg: #dc2626;
  --neg-soft: #fef2f2;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --sys: #3b5bdb;      /* 시스템등록가 그룹 색 */
  --sys-soft: #eef3ff;
  --sys-tint: #f6f8ff;
  --sale: #b45309;     /* 판매가 설정 그룹 색 */
  --sale-soft: #fff4e0;
  --sale-tint: #fffaf1;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.04), 0 1px 3px rgba(17, 24, 39, 0.06);
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 1;
}
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 16px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; color: var(--text); display: flex; align-items: center; gap: 8px; }
h3::before { content: ""; width: 3px; height: 14px; border-radius: 2px; background: var(--accent); }
h3 .small { font-weight: 400; color: var(--text-3); }
p { margin: 0; }
.muted { color: var(--text-3); }
.small { font-size: 12px; font-weight: 400; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- top bar: 브랜드 + 아이콘 가로 메뉴 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  height: 60px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); padding-right: 20px; margin-right: 8px; border-right: 1px solid var(--line); height: 32px; }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.logo {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 16px;
}
.tabs { display: flex; align-items: center; gap: 4px; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; cursor: pointer;
  font: inherit; font-size: 14px; color: var(--text-2); font-weight: 500; white-space: nowrap; transition: background .12s, color .12s;
}
.tab svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.tab svg .knob { fill: var(--surface); }
.tab:hover { background: var(--surface-3); color: var(--text); }
.tab.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); font-weight: 700; }
.tab.active svg .knob { fill: var(--accent-soft); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-2); padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line);
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.status.api::before { background: var(--pos); }
.status.local::before { background: var(--warn); }
.switch-link { font-size: 12px; color: var(--text-3); text-decoration: none; }
.switch-link:hover { color: var(--accent); text-decoration: underline; }

main { padding: 20px; max-width: 1800px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

/* ---------- buttons / fields ---------- */
.btn, .menu-list button, .menu-list label {
  font: inherit; font-size: 13px; font-weight: 500; line-height: 1;
  padding: 9px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-2);
  background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); border-color: #b8bec8; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.subtle { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.subtle:hover { background: var(--surface-3); color: var(--text); }
.btn.danger { color: var(--neg); }
.btn.danger:hover { background: var(--neg-soft); border-color: #fca5a5; }
.btn.sm { padding: 6px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.icon { width: 36px; padding: 0; justify-content: center; font-size: 16px; }

input[type="text"], input[type="search"], input[type="date"], select {
  font: inherit; font-size: 13px; color: var(--text); background: var(--surface);
  height: 36px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); min-width: 0;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: var(--text-3); }
.withunit { display: inline-flex; align-items: center; gap: 6px; }
.unit { color: var(--text-3); font-size: 12px; flex-shrink: 0; }

/* 라벨형 필드 그리드 */
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field .lbl { font-size: 12px; color: var(--text-2); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.field input, .field select { width: 100%; }
.field .withunit { display: flex; }
.field .withunit input { flex: 1 1 0; width: 0; }
.fields.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 900px) { .fields.five { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); } }

/* segmented control */
.seg { display: inline-flex; padding: 3px; background: var(--surface-3); border-radius: 9px; }
.seg button { font: inherit; font-size: 12px; font-weight: 500; border: 0; background: transparent; color: var(--text-2); padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }

/* dropdown menu */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 200px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(17, 24, 39, .12); padding: 6px;
  display: flex; flex-direction: column;
}
.menu-list button, .menu-list label { border: 0; border-radius: 6px; padding: 9px 10px; justify-content: flex-start; font-weight: 400; }
.menu-list button:hover, .menu-list label:hover { background: var(--surface-2); }
.menu-list hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

/* ---------- panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; }
.panel-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--surface); }
.panel-title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.panel-title .count { font-size: 12px; font-weight: 500; color: var(--text-2); background: var(--surface-3); border-radius: 999px; padding: 2px 9px; }
.panel-title .step { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; }
.panel-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.panel-body { padding: 20px; }
.panel-body + .panel-body { border-top: 1px solid var(--line); }
.sub { margin-bottom: 26px; }
.sub:last-child { margin-bottom: 0; }
.sub > h3 { margin-bottom: 12px; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
details.panel > summary { list-style: none; cursor: pointer; padding: 14px 20px; display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::before { content: "▸"; color: var(--text-3); font-size: 12px; }
details.panel[open] > summary { border-bottom: 1px solid var(--line); }
details.panel[open] > summary::before { content: "▾"; }

/* ---------- 문서 패널: 제목·메모·요약·계산표·물류비를 하나로 ---------- */
.doc-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.doc-header {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 22px 28px 18px; background: linear-gradient(180deg, #fbfcfe 0%, var(--surface) 100%); border-bottom: 1px solid var(--line);
}
.doc-h-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.doc-kicker { font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--accent); text-transform: uppercase; }
.title-input {
  font-size: 24px; font-weight: 700; height: 46px; padding: 0 10px; margin-left: -10px; border-color: transparent; background: transparent; width: 100%; letter-spacing: -0.01em;
}
.title-input:hover { border-color: var(--line); background: var(--surface); }
.title-input:focus { background: var(--surface); }
.memo-input { font-size: 13px; height: 34px; padding: 0 10px; margin-left: -10px; border-color: transparent; background: transparent; width: 100%; color: var(--text-2); }
.memo-input:hover { border-color: var(--line); background: var(--surface); }
.memo-input:focus { background: var(--surface); color: var(--text); }
.doc-state { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.doc-state.dirty { color: var(--warn); }
.doc-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.doc-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.doc-kpis .kpi { border: 0; border-right: 1px solid var(--line); border-radius: 0; box-shadow: none; background: transparent; padding: 14px 20px 12px 22px; }
.doc-kpis .kpi:last-child { border-right: 0; }
.doc-section { border-bottom: 1px solid var(--line); }
.doc-section:last-child { border-bottom: 0; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 20px 12px; }
.sec-head h2 { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.sec-no { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; }
.doc-section .legend { padding: 10px 20px 14px; margin: 0; background: var(--surface-2); }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px 14px; min-width: 0; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--line-2); }
.kpi.k1::before { background: #94a3b8; }
.kpi.k2::before { background: var(--sys); }
.kpi.k3::before { background: var(--sale); }
.kpi.k4::before { background: var(--text-3); }
.kpi.pos::before { background: var(--pos); }
.kpi.neg::before { background: var(--neg); }
.kpi .k-label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.kpi .k-value { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; margin-top: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .k-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.kpi.pos .k-value { color: var(--pos); }
.kpi.neg .k-value { color: var(--neg); }

/* ---------- grid table (계산표) ---------- */
.table-wrap { overflow: auto; max-height: calc(100vh - 300px); min-height: 120px; }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
.grid th, .grid td {
  padding: 0 10px; height: 44px; white-space: nowrap; vertical-align: middle;
  border-bottom: 1px solid var(--line); border-right: 1px solid var(--line-soft);
}
.grid th:last-child, .grid td:last-child { border-right: 0; }
.grid th.gs, .grid td.gs { border-left: 2px solid var(--line-2); }          /* 그룹 경계 */
.grid thead th { position: sticky; z-index: 4; background: var(--surface-2); color: var(--text-2); font-weight: 600; font-size: 12px; text-align: right; }
.grid thead tr.grp th { top: 0; height: 30px; font-size: 11px; font-weight: 600; letter-spacing: .03em; color: var(--text-3); text-align: left; padding-left: 12px; }
.grid thead tr.grp th.g-sys { background: var(--sys-soft); color: var(--sys); }
.grid thead tr.grp th.g-sale { background: var(--sale-soft); color: var(--sale); }
.grid thead tr.cols th { top: 30px; height: 38px; border-bottom: 1px solid var(--line-2); }
.grid thead tr.cols th.g-sys { background: var(--sys-tint); }
.grid thead tr.cols th.g-sale { background: var(--sale-tint); }
.grid thead tr.single th { top: 0; height: 38px; border-bottom: 1px solid var(--line-2); }
.grid th.l, .grid td.l { text-align: left; }
.grid th.c, .grid td.c { text-align: center; }
.grid th.no, .grid td.no { width: 40px; min-width: 40px; max-width: 40px; padding: 0; text-align: center; color: var(--text-3); font-size: 12px; }
/* 열 최소 폭: 표가 패널 폭을 채우되 각 열이 너무 좁아지지 않게 (핵심 열 14개가 1700px 화면에 맞도록) */
.grid th.w-name { min-width: 180px; }
.grid th.w-num { min-width: 100px; }
.grid th.w-pct { min-width: 96px; }
.grid th.w-grade { min-width: 76px; }
.grid th.w-out { min-width: 102px; }
.grid tbody tr:nth-child(even) td { background: var(--zebra); }
.grid tbody tr:hover td { background: var(--hover); }
.grid td.in { padding: 0 6px; }
.grid td.in input, .grid td.in select {
  width: 100%; height: 32px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); font-size: 13px;
}
.grid td.in input.num { text-align: right; }
.grid td.in select { padding-right: 4px; text-align: center; }
.grid td.in .withunit { display: flex; }
.grid td.in .withunit input { flex: 1 1 0; width: 0; min-width: 48px; }
.grid td.in input:hover, .grid td.in select:hover { border-color: var(--line-2); }
.grid td.in input:focus, .grid td.in select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.grid td.name input { text-align: left; }
.grid td.out { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }
.grid td.out.dim { color: var(--text-2); }
.grid td.out.strong { font-weight: 600; }
.grid td.out.profit.pos { color: var(--pos); }
.grid td.out.profit.neg { color: var(--neg); }
.grid td.out.grade { text-align: center; }
.grid td.act, .grid th.act { width: 64px; min-width: 64px; padding: 0 2px; text-align: center; }
.grid td.act .btn { padding: 0; width: 28px; height: 28px; justify-content: center; border-color: transparent; background: transparent; color: var(--text-3); font-size: 13px; }
.grid tbody tr:hover td.act .btn { color: var(--text-2); }
.grid td.act .btn:hover { background: var(--surface); border-color: var(--line-2); color: var(--text); }
.grid td.act .btn.danger:hover { color: var(--neg); border-color: #fca5a5; }
.grid tfoot td { position: sticky; bottom: 0; z-index: 3; background: var(--surface-3); border-top: 2px solid var(--line-2); border-bottom: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.grid tfoot td.label { text-align: center; color: var(--text-2); font-weight: 600; }
/* 고정 열 (No, 상품명) */
.grid .fx1 { position: sticky; left: 0; z-index: 2; background: var(--surface); }
.grid .fx2 { position: sticky; left: 40px; z-index: 2; background: var(--surface); box-shadow: 1px 0 0 var(--line); }
.grid thead .fx1, .grid thead .fx2 { z-index: 5; background: var(--surface-2); }
.grid tfoot .fx1, .grid tfoot .fx2 { background: var(--surface-3); }
.grid tbody tr:nth-child(even) td.fx1, .grid tbody tr:nth-child(even) td.fx2 { background: var(--zebra); }
.grid tbody tr:hover td.fx1, .grid tbody tr:hover td.fx2 { background: var(--hover); }
.grid td.empty { text-align: center; color: var(--text-3); height: 96px; }

.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 24px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.g1 { background: #fee2e2; color: #b91c1c; }
.badge.g2 { background: #ffedd5; color: #c2410c; }
.badge.g3 { background: #fef3c7; color: #a16207; }
.badge.g4 { background: #dcfce7; color: #15803d; }
.badge.g5 { background: #dbeafe; color: #1d4ed8; }

.grid thead tr.grp th.g-custom { background: #f0fdf4; color: #15803d; }
.grid thead tr.cols th.g-custom { background: #f6fef9; }
.basis-line { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; padding: 12px 20px; border-top: 1px solid var(--line); font-size: 12px; color: var(--text-2); background: var(--surface-2); }
.basis-line > span:first-child { font-weight: 600; color: var(--text-3); letter-spacing: .03em; }
.basis-line b { color: var(--text); font-weight: 600; }
.basis-line a { color: var(--accent); cursor: pointer; margin-left: auto; font-weight: 500; }
.basis-line a:hover { text-decoration: underline; }
details.formula { padding: 0 20px 12px; font-size: 12px; color: var(--text-2); background: var(--surface-2); }
details.formula summary { cursor: pointer; color: var(--text-3); padding: 6px 0; list-style: none; }
details.formula summary::-webkit-details-marker { display: none; }
details.formula summary::before { content: "▸ "; }
details.formula[open] summary::before { content: "▾ "; }
details.formula div { line-height: 1.9; padding-bottom: 6px; }
details.formula code { font-family: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }

/* ---------- board ---------- */
.search { display: flex; gap: 6px; }
.search input { width: 280px; }
/* 게시판 목록: 계산표와 같은 격자 규칙 (열 구분선 · 줄무늬 · 고정 헤더) */
table.board { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
table.board th, table.board td {
  padding: 0 14px; height: 48px; white-space: nowrap; vertical-align: middle; text-align: left;
  border-bottom: 1px solid var(--line); border-right: 1px solid var(--line-soft);
}
table.board th:last-child, table.board td:last-child { border-right: 0; }
table.board thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--text-2); font-weight: 600; font-size: 12px; height: 40px; border-bottom: 1px solid var(--line-2); }
table.board tbody tr:nth-child(even) td { background: var(--zebra); }
table.board tbody tr:hover td { background: var(--hover); }
table.board th.no, table.board td.no { width: 56px; min-width: 56px; padding: 0; text-align: center; color: var(--text-3); font-size: 12px; }
table.board th.w-title { min-width: 260px; }
table.board td.title { font-weight: 600; color: var(--text); cursor: pointer; }
table.board td.title::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--accent); margin-right: 10px; vertical-align: 1px; }
table.board td.title:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
table.board td.ellipsis { max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
table.board td.dim { color: var(--text-2); }
table.board td.dim:empty::before, table.board td.dim.none { color: var(--text-3); }
table.board th.num, table.board td.num { text-align: right; width: 72px; font-variant-numeric: tabular-nums; }
table.board th.date, table.board td.date { text-align: right; width: 150px; font-variant-numeric: tabular-nums; }
table.board td.date { color: var(--text-3); font-size: 12px; }
.pager:empty { display: none; }
table.board th.act, table.board td.act { width: 116px; min-width: 116px; padding: 0 6px; text-align: center; }
table.board td.act .btn { margin: 0 2px; }
table.board td.act .btn.x { padding: 0; width: 28px; height: 28px; justify-content: center; border-color: transparent; background: transparent; color: var(--text-3); }
table.board tbody tr:hover td.act .btn.x { color: var(--text-2); }
table.board td.act .btn.x:hover { background: var(--surface); border-color: #fca5a5; color: var(--neg); }
table.board td.empty { text-align: center; color: var(--text-3); height: 120px; }
.pager { display: flex; gap: 4px; align-items: center; justify-content: center; padding: 14px; flex-wrap: wrap; border-top: 1px solid var(--line); background: var(--surface-2); }
.pager button { font: inherit; font-size: 12px; font-weight: 500; min-width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); cursor: pointer; color: var(--text-2); }
.pager button:hover { border-color: var(--line-2); color: var(--text); }
.pager button.cur { background: var(--accent); border-color: var(--accent); color: #fff; }
.pager .info { color: var(--text-3); font-size: 12px; margin-right: 8px; }

/* ---------- settings ---------- */
table.settings { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
table.settings th, table.settings td {
  padding: 0 10px; height: 44px; white-space: nowrap; vertical-align: middle; text-align: right;
  border-bottom: 1px solid var(--line); border-right: 1px solid var(--line-soft);
}
table.settings th:last-child, table.settings td:last-child { border-right: 0; }
table.settings thead th { background: var(--surface-2); color: var(--text-2); font-weight: 600; font-size: 12px; line-height: 1.3; height: 46px; border-bottom: 1px solid var(--line-2); }
table.settings th.c, table.settings td.c { text-align: center; }
table.settings th.l, table.settings td.l { text-align: left; }
table.settings th.no, table.settings td.no { width: 56px; text-align: center; color: var(--text-3); }
table.settings tbody tr:nth-child(even) td { background: var(--zebra); }
table.settings td.in { padding: 0 6px; }
table.settings td.in input { width: 100%; min-width: 88px; height: 32px; padding: 0 8px; text-align: right; border-color: var(--line); }
table.settings td.in select { width: 100%; height: 32px; padding: 0 6px; border-color: var(--line); }
table.settings td.in .withunit { display: flex; }
table.settings td.in .withunit input { flex: 1 1 0; width: 0; min-width: 60px; }
table.settings td.out { color: var(--text-2); font-variant-numeric: tabular-nums; }
table.settings td.muted { color: var(--text-3); font-size: 12px; text-align: center; }
/* 구간표 (세로 목록) */
table.settings.tiers td.range { text-align: left; padding: 0 12px; }
table.settings.tiers .rng { display: flex; align-items: center; gap: 8px; }
table.settings.tiers td.range .lo { min-width: 64px; text-align: right; color: var(--text-3); font-variant-numeric: tabular-nums; }
table.settings.tiers td.range .tilde { color: var(--text-3); }
table.settings.tiers td.range input { width: 110px; height: 32px; padding: 0 8px; text-align: right; border-color: var(--line); }
table.settings.tiers td.range .unit { color: var(--text-2); }
table.settings.tiers td.range.open .lo { color: var(--text); font-weight: 600; }
table.settings.tiers td.val { width: 160px; }
.tier-actions { display: flex; gap: 6px; justify-content: flex-end; padding: 10px 0 0; }
#view-settings .table-wrap { max-height: none; min-height: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); }
#view-settings .table-wrap table.settings tbody tr:last-child td { border-bottom: 0; }
.settings-note { font-size: 12px; color: var(--text-3); line-height: 1.7; }
.actions-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 14px 20px; }
.actions-row .spacer { flex: 1; }
.sticky-actions { position: sticky; bottom: 0; background: rgba(255, 255, 255, .94); backdrop-filter: blur(6px); border-top: 1px solid var(--line); }
.sub.narrow { max-width: 760px; }

/* 기준값 설정 하위 탭 */
.subbar { gap: 20px; }
.subtabs { display: flex; gap: 4px; flex-wrap: wrap; }
.subtabs button {
  font: inherit; font-size: 13px; font-weight: 500; color: var(--text-2); background: transparent; border: 1px solid transparent;
  height: 36px; padding: 0 14px; border-radius: 9px; cursor: pointer; white-space: nowrap;
}
.subtabs button:hover { background: var(--surface-3); color: var(--text); }
.subtabs button.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); font-weight: 700; }
.spane { display: none; }
.spane.on { display: block; }

/* 계산식 설정 */
.formulas-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 0; }
.formulas-main { padding: 20px; min-width: 0; }
.formulas-ref { padding: 20px; border-left: 1px solid var(--line); background: var(--surface-2); font-size: 12px; }
.formulas-ref h3 { margin: 0 0 10px; }
.formulas-ref h3 + h3, .formulas-ref dl + h3, .formulas-ref p + h3 { margin-top: 18px; }
.formulas-ref dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; }
.formulas-ref dt { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 11.5px; color: var(--accent); white-space: nowrap; }
.formulas-ref dd { margin: 0; color: var(--text-2); }
.formulas-ref code, .settings-note code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
table.settings.formulas td { white-space: normal; height: auto; padding: 8px 10px; }
table.settings.formulas td.l, table.settings.formulas th.l { text-align: left; }
table.settings.formulas td.item b { display: block; }
table.settings.formulas td.item .excel { font-size: 11px; color: var(--text-3); }
table.settings.formulas td.item .desc { font-size: 12px; color: var(--text-2); }
table.settings.formulas td.def { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; color: var(--text-2); min-width: 220px; }
table.settings.formulas td.in input.fx { width: 100%; min-width: 260px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; text-align: left; }
table.settings.formulas td.in input.fx.changed { border-color: var(--accent); background: var(--accent-soft); }
table.settings.formulas td.in input.fx.err { border-color: #fca5a5; background: var(--neg-soft); }
table.settings.formulas td.in input.short { width: 150px; min-width: 120px; text-align: left; }
table.settings.formulas td.prev { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 110px; }
table.settings.formulas td.prev.err { color: var(--neg); font-size: 11px; white-space: normal; max-width: 220px; }
table.settings.formulas .fx-err { display: block; font-size: 11px; color: var(--neg); margin-top: 4px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; z-index: 50;
  box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: 90vw;
}
.toast.error { background: var(--neg); }
.toast.ok { background: var(--pos); }

@media (max-width: 1100px) {
  .two-col { grid-template-columns: 1fr; }
  .formulas-layout { grid-template-columns: 1fr; }
  .formulas-ref { border-left: 0; border-top: 1px solid var(--line); }
}
/* 휴대폰 화면은 반응형으로 줄이지 않고 전용 모바일 프로그램(/m/)이 담당합니다. PC 화면은 최소 폭을 유지합니다. */
body { min-width: 960px; }
