/* 공통 스타일. 색은 여기 변수로만 정하고, 화면별 스타일은 이 변수를 쓴다. */
/* 글꼴: Pretendard (SIL OFL 1.1, static/fonts/Pretendard-LICENSE.txt). 외부 서버에서 불러오지 않고 사이트에 둔 파일을 쓴다. */
@font-face { font-family: "Pretendard"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/Pretendard-Regular.subset.woff2") format("woff2"); }
@font-face { font-family: "Pretendard"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/Pretendard-SemiBold.subset.woff2") format("woff2"); }
@font-face { font-family: "Pretendard"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/Pretendard-Bold.subset.woff2") format("woff2"); }
:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --fg: #17212b;
  --fg-2: #4a5866;
  --fg-3: #77838f;
  --line: #dde3ea;
  --accent: #1f5f99;
  --accent-fg: #ffffff;
  --accent-soft: #e6eff8;
  --good: #1b7a48;
  --bad: #c0362c;
  --bad-bg: #fbe9e7;
  --mark-bg: #fff3cd;
  --mark-fg: #6b4f00;
  /* 조달 화면에서 쓰는 색 */
  --sunken: #e9edf1;
  --line-soft: #e8ecf0;
  --up: #0d6b4f; --up-bg: #dff3ea;
  --low: #0d6b4f; --low-bg: #dff3ea;
  --warn: #a23b1d; --warn-bg: #fbe6de;
  --exc: #8a5a00; --exc-bg: #fbefd2;
  --radius: 8px;
  --width: 1120px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161c;
    --surface: #1a2129;
    --fg: #e8edf2;
    --fg-2: #b3bfca;
    --fg-3: #8693a0;
    --line: #2c3742;
    --accent: #7fb6e8;
    --accent-fg: #0d1620;
    --accent-soft: #1d2c3a;
    --good: #6fd3a0;
    --bad: #ff8f85;
    --bad-bg: #3a1f1c;
    --mark-bg: #3a2e12;
    --mark-fg: #f0c36a;
    --sunken: #212b35;
    --line-soft: #28333e;
    --up: #6fd3ae; --up-bg: #143328;
    --low: #6fd3ae; --low-bg: #143328;
    --warn: #f09a7e; --warn-bg: #40211a;
    --exc: #f0c36a; --exc-bg: #3a2e12;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 15.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
}
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { width: 100%; max-width: var(--width); margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; background: var(--surface); padding: 6px 10px; z-index: 10; }

/* 머리 */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 24px; min-height: 56px; }
.brand { font-weight: 700; font-size: 18px; color: var(--fg); text-decoration: none; letter-spacing: -0.01em; }
.site-nav { display: flex; flex-wrap: wrap; gap: 0 4px; margin-left: auto; }
.site-nav a {
  padding: 16px 12px 13px;
  color: var(--fg-2);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 3px solid transparent;
}
.site-nav a:hover { color: var(--fg); }
.site-nav a[aria-current="page"] { color: var(--fg); border-bottom-color: var(--accent); }

/* 본문 */
.main { flex: 1; padding-top: 28px; padding-bottom: 56px; }
.main.wide { max-width: 1320px; }
h1 { font-size: 24px; line-height: 1.3; margin: 0 0 6px; letter-spacing: -0.02em; }
h2 { font-size: 19px; margin: 0; }
h3 { font-size: 16px; margin: 0 0 6px; }
.lead { color: var(--fg-2); margin: 0 0 20px; max-width: 70ch; }
.crumb { margin: 0 0 8px; font-size: 14px; }
.crumb a { text-decoration: none; }
.crumb a::before { content: "← "; }

.intro { margin-bottom: 32px; }
.intro p { color: var(--fg-2); margin: 0; max-width: 70ch; }
.section-head { margin: 32px 0 12px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.asof { color: var(--fg-3); font-size: 13.5px; }
.section-head.first { margin-top: 0; }
.section-head h1 { margin: 0; }
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 0 0 12px; }
.figures > a { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; color: inherit; text-decoration: none; }
.figures > a:hover { border-color: var(--accent); }

/* 홈의 업체 순위 */
.rank-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
.rank-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 12px; margin-bottom: 8px; }
.rank-head h3 { margin: 0; font-size: 15px; }
.rank-head a { font-size: 13.5px; text-decoration: none; }
.rank ol { list-style: none; margin: 0; padding: 0; }
.rank li { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto 90px 46px; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line-soft); font-size: 14.5px; font-variant-numeric: tabular-nums; }
.rank-no { color: var(--fg-3); text-align: right; }
.rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-amt { font-weight: 600; text-align: right; }
.rank-amt small { margin-left: 1px; }
.rank-bar { height: 8px; background: var(--sunken); border-radius: 2px; overflow: hidden; }
.rank-bar span { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.rank-share { color: var(--fg-2); font-size: 13px; text-align: right; }
@media (max-width: 480px) {
  .rank li { grid-template-columns: 18px minmax(0, 1fr) auto 44px; }
  .rank-bar { display: none; }
}
.figures .k { display: block; font-size: 13.5px; color: var(--fg-2); }
.figures .v { display: block; margin: 2px 0 0; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.figures .v small { font-size: 14px; margin-left: 4px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  color: inherit;
  text-decoration: none;
}
.card:hover { border-color: var(--accent); }
.card h3 { color: var(--accent); }
.card p { margin: 0; color: var(--fg-2); font-size: 14.5px; }

.tabs { display: flex; flex-wrap: wrap; gap: 0 4px; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.tabs a {
  padding: 8px 14px 9px;
  color: var(--fg-2);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
}
.tabs a:hover { color: var(--fg); }
.tabs a[aria-current="page"] { color: var(--fg); border-bottom-color: var(--accent); }

.notice {
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--fg-2);
}

.button {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-fg);
  padding: 9px 16px;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 600;
}

/* 계산 도구: 입력과 결과 */
.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 16px; align-items: start; }
.split.side { grid-template-columns: 340px minmax(0, 1fr); }
.split.table-left { grid-template-columns: minmax(0, 640px) minmax(0, 1fr); }
.split.result-right { grid-template-columns: minmax(0, 1fr) 360px; }
/* 결과 칸은 입력을 내려가며 채우는 동안 화면에 남는다. */
.sticky { position: sticky; top: 16px; }
.stack { display: grid; gap: 16px; }
.narrow { max-width: 820px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; min-width: 0; }
.panel-title { font-size: 15px; margin: 22px 0 12px; padding-left: 9px; border-left: 3px solid var(--accent); }
.panel-title:first-child { margin-top: 0; }
.sub-title { font-size: 14px; margin: 18px 0 10px; color: var(--fg-2); }
small { font-weight: 400; color: var(--fg-3); font-size: 0.9em; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid.one { grid-template-columns: minmax(0, 1fr); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.field { display: block; font-size: 13.5px; font-weight: 600; color: var(--fg-2); border: 0; padding: 0; margin: 0; min-width: 0; }
.field > input, .field > select, .field > div { display: block; margin-top: 5px; }
.field > .hint { display: block; margin-top: 4px; }
.field legend { padding: 0; margin-bottom: 5px; }
p.hint { margin-bottom: 12px; }
input[type="text"], input[type="number"], select {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-size: 14.5px;
  font-weight: 400;
}
input[type="file"] { font: inherit; font-size: 14px; font-weight: 400; color: var(--fg-2); max-width: 100%; }
input:disabled { background: var(--bg); color: var(--fg-3); }
input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.hint { font-size: 12.5px; font-weight: 400; color: var(--fg-3); margin: 0; }
.hint.warn { color: var(--bad); font-weight: 600; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.checks legend { float: left; width: 100%; }
.checks label, .check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 400; color: var(--fg); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.btn {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--surface);
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: var(--accent-fg); }
.actions .btn.primary { flex: 1; }
.btn.wide { width: 100%; min-height: 46px; font-size: 16px; }
.btn.small { min-height: 26px; padding: 0 8px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.status { min-height: 1.6em; margin: 10px 0 0; font-size: 14px; color: var(--fg-3); white-space: pre-line; }
.status[data-kind="busy"] { color: var(--accent); }
.status[data-kind="ok"] { color: var(--good); }
.status[data-kind="error"] { color: var(--bad); font-weight: 600; }
.result-note { margin: 10px 0 0; padding: 8px 12px; border: 2px solid var(--bad); color: var(--bad); font-weight: 700; text-align: center; border-radius: 6px; }

.preview { min-height: 420px; display: flex; align-items: center; justify-content: center; background: #ffffff; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.preview img { max-width: 100%; height: auto; display: block; }
.placeholder { color: var(--fg-3); text-align: center; padding: 40px 16px; margin: 0; }
.preview .placeholder { color: #77838f; }

.table-scroll { overflow-x: auto; }
table.grid-input { border-collapse: collapse; font-size: 12.5px; min-width: 590px; width: 100%; }
table.grid-input th, table.grid-input td { border: 1px solid var(--line); padding: 3px; text-align: center; }
table.grid-input th { background: var(--accent-soft); font-weight: 600; line-height: 1.25; padding: 5px 3px; }
table.grid-input input[type="number"] { min-height: 30px; padding: 3px 5px; text-align: right; font-size: 13px; border-color: transparent; min-width: 44px; -moz-appearance: textfield; appearance: textfield; }
table.grid-input input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

table.data { border-collapse: collapse; width: 100%; font-size: 13.5px; }
table.data th, table.data td { border: 1px solid var(--line); padding: 5px 9px; text-align: left; }
table.data th { background: var(--accent-soft); font-weight: 600; white-space: nowrap; }
table.data.center th, table.data.center td { text-align: center; }
table.data.formula td:nth-child(2) { color: var(--fg-2); font-size: 12.5px; word-break: break-all; }
table.data.formula td:last-child { text-align: right; font-weight: 700; white-space: nowrap; color: var(--accent); }
table.data tr.current td, table.data tr.standard td { background: var(--accent-soft); font-weight: 700; }
table.data tr.install td { background: var(--mark-bg); color: var(--mark-fg); font-weight: 700; }
.table-caption { font-size: 13px; font-weight: 600; margin: 12px 0 4px; }

.info-box { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; margin: 12px 0; font-size: 13.5px; }
.info-box p { margin: 0 0 8px; color: var(--fg-2); }
.photos { display: flex; flex-wrap: wrap; gap: 8px; }
.photo { position: relative; }
.photo img { width: 100px; height: 75px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); display: block; }
.photo button { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border: 0; border-radius: 50%; background: var(--bad); color: #fff; font-weight: 700; line-height: 1; cursor: pointer; padding: 0; }

.result-title { font-size: 14.5px; color: var(--accent); margin: 18px 0 6px; }
.result-title:first-child { margin-top: 0; }
dl.kv { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 2px 10px; margin: 0; font-size: 13.5px; }
dl.kv dt { color: var(--fg-3); }
dl.kv dd { margin: 0; }
.result-box { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 14px; padding: 8px 14px; border-radius: 6px; margin: 8px 0 0; font-size: 14px; }
.result-box.strong { background: var(--accent); color: var(--accent-fg); font-weight: 700; }
.result-box.good { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.result-box.bad { background: var(--bad-bg); color: var(--bad); font-weight: 700; }
.result-box.mark { background: var(--mark-bg); color: var(--mark-fg); }
.result-box.mark span:last-child { font-weight: 700; }
.result-box:first-child { margin-top: 0; }
.verdict { display: inline-block; min-width: 44px; padding: 1px 8px; border-radius: 4px; font-size: 13px; font-weight: 700; text-align: center; }
.verdict.ok { background: var(--up-bg); color: var(--up); }
.verdict.ng { background: var(--bad-bg); color: var(--bad); }
table.data.checks { margin-top: 10px; }
table.data.checks td { border-left: 0; border-right: 0; padding: 8px 2px; }
table.data.checks td:first-child { display: grid; grid-template-columns: auto 1fr; gap: 0 10px; }
table.data.checks .k { color: var(--fg-3); }
table.data.checks td.mark { text-align: right; vertical-align: middle; width: 60px; }
dl.kv dd { font-variant-numeric: tabular-nums; }

dl.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0; }
dl.stats.one { grid-template-columns: minmax(0, 1fr); }
dl.stats dt { font-size: 13px; color: var(--fg-3); }
dl.stats dd { margin: 2px 0 0; font-size: 17px; font-weight: 700; color: var(--accent); }

.skew-figure { width: 100%; max-height: 130px; color: var(--fg-3); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }
.skew-figure .accent-fill { fill: var(--accent); }
.skew-figure .accent-stroke { stroke: var(--accent); }

@media (max-width: 900px) {
  .split, .split.side, .split.table-left, .split.result-right { grid-template-columns: minmax(0, 1fr); }
  .sticky { position: static; }
}
@media (max-width: 560px) {
  .form-grid, .form-grid.three, dl.stats { grid-template-columns: minmax(0, 1fr); }
  .panel { padding: 14px; }
}

/* 조달 화면: 화면별 스타일(procurement_*.css)이 들어가는 구역 */
.proc { display: flex; flex-direction: column; gap: 12px; font-size: 14px; line-height: 1.5; min-width: 0; }
.proc .panel { padding: 0; }
.proc .filters { padding: 12px 14px; }
/* 숫자는 같은 글꼴에서 자릿수 폭만 맞춘다(고정폭 글꼴을 쓰지 않는다). */
.proc .num, table.data, dl.stats dd { font-variant-numeric: tabular-nums; }
/* 스크롤해도 표 머리글이 위에 남는다. */
.proc .panel > .scroll > table > thead { position: sticky; top: 0; z-index: 2; }
.proc .panel > .scroll > table > thead th { box-shadow: inset 0 -1px 0 var(--line); }
/* 좁은 화면: 조건은 접어 두고 버튼으로 펼친다. */
.filter-toggle { display: none; }
@media (max-width: 720px) {
  .filter-toggle { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--fg); font: inherit; font-weight: 600; cursor: pointer; }
  .filter-toggle::after { content: "▾"; color: var(--fg-3); }
  .filter-toggle[aria-expanded="true"]::after { content: "▴"; }
  .proc .filters:not(.open) { display: none; }
  /* 순위 표는 가로로 밀어도 이름 열이 남는다. */
  .proc table:has(tr.agg) th:nth-child(2), .proc tr.agg td:nth-child(2) { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: inset -1px 0 0 var(--line-soft); }
  .proc table:has(tr.agg) th:nth-child(2) { background: var(--sunken); }
  .proc tr.agg td.wrapc { min-width: 120px; max-width: 150px; }
}

/* 발 */
.site-footer { border-top: 1px solid var(--line); color: var(--fg-3); font-size: 14px; }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 24px; padding-top: 18px; padding-bottom: 22px; }
.site-footer a { color: inherit; }

@media (max-width: 560px) {
  .site-nav { margin-left: -12px; width: 100%; }
  .site-nav a { padding: 8px 12px 9px; }
  h1 { font-size: 22px; }
}
