/* 환경입찰 레이더 — 메인 보드
   색: 분류 4색은 검증된 기본 팔레트 1~4번(고정 순서), 마감 임박은 상태색(글자와 함께만 사용) */
:root {
  color-scheme: light;
  --bg: #f6f6f4;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e4e3df;
  --border-strong: #cfcec9;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #6f6e69;
  --link-hover: #1c5cab;
  --c-eia1: #2a78d6;
  --c-eco2: #eb6834;
  --c-measure: #1baf7a;
  --c-academic: #eda100;
  --st-critical: #d03b3b;
  --st-serious: #ec835a;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #262624;
    --border: #2f2f2c;
    --border-strong: #45453f;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --text-3: #9a998f;
    --link-hover: #86b6ef;
    --c-eia1: #3987e5;
    --c-eco2: #d95926;
    --c-measure: #199e70;
    --c-academic: #c98500;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211;
  --surface: #1a1a19;
  --surface-2: #262624;
  --border: #2f2f2c;
  --border-strong: #45453f;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --text-3: #9a998f;
  --link-hover: #86b6ef;
  --c-eia1: #3987e5;
  --c-eco2: #d95926;
  --c-measure: #199e70;
  --c-academic: #c98500;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
        "Malgun Gothic", "Noto Sans KR", sans-serif;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 768px) { .wrap { padding: 0 24px; } }

/* 상단 */
.top { background: var(--surface); border-bottom: 1px solid var(--border); }
.top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 4px 16px; flex-wrap: wrap; min-height: 56px; padding-top: 8px; padding-bottom: 8px; }
.brand { color: var(--text); text-decoration: none; font-weight: 700; font-size: 17px; letter-spacing: -0.02em; }
.updated { color: var(--text-3); font-size: 13px; font-variant-numeric: tabular-nums; }

.intro { padding: 24px 0 4px; }
.intro h1 { margin: 0 0 4px; font-size: 22px; line-height: 1.3; letter-spacing: -0.03em; font-weight: 700; }
.intro p { margin: 0; color: var(--text-2); font-size: 14px; }

/* 요약 타일 */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 16px 0; }
@media (min-width: 768px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stat .label { font-size: 13px; color: var(--text-2); }
.stat .value { font-size: 28px; font-weight: 650; line-height: 1.2; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .value small { font-size: 14px; font-weight: 500; color: var(--text-2); margin-left: 2px; }
.stat .sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* 광고 자리 (애드센스 승인 전 표시용) */
.ad-slot { display: flex; align-items: center; justify-content: center; min-height: 90px; margin: 16px 0; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); color: var(--text-3); font-size: 12px; letter-spacing: 0.08em; }
li.ad-slot.infeed { min-height: 72px; margin: 0; border: 0; border-top: 1px solid var(--border); border-radius: 0; }

/* 탭 */
.tabs { display: flex; gap: 4px; margin-top: 24px; border-bottom: 1px solid var(--border); }
.tab { appearance: none; background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: 10px 12px; font: inherit; font-size: 16px; font-weight: 650; color: var(--text-3); cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); }
.tab .n { margin-left: 6px; font-size: 14px; font-weight: 500; color: var(--text-3); font-variant-numeric: tabular-nums; }
.tab:focus-visible, .chip:focus-visible, select:focus-visible, input:focus-visible, .title:focus-visible { outline: 2px solid var(--c-eia1); outline-offset: 2px; }

/* 필터 */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 14px 0 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border: 1px solid var(--border); border-radius: 17px; background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; }
.chip:hover { border-color: var(--border-strong); }
.chip .n { color: var(--text-3); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip[aria-pressed="true"] .n { color: inherit; opacity: 0.7; }
.chip[aria-pressed="true"] .dot { box-shadow: 0 0 0 2px var(--text); }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
select, input[type="search"] { height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 14px; }
input[type="search"] { width: 200px; }
input[type="search"]::placeholder { color: var(--text-3); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-2); cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--text); }
@media (max-width: 720px) {
  .controls { margin-left: 0; width: 100%; }
  .controls select { flex: 0 0 auto; }
  .controls input[type="search"] { flex: 1 1 140px; min-width: 0; width: auto; }
}
.result { margin: 4px 0 10px; font-size: 13px; color: var(--text-3); }
.result [data-count] { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* 분류 표시: 색 점 + 글자 (색만으로 구분하지 않음) */
.dot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 2px; background: var(--text-3); }
[data-cat="eia1"] > .dot, .dot[data-cat="eia1"] { background: var(--c-eia1); }
[data-cat="eco2"] > .dot, .dot[data-cat="eco2"] { background: var(--c-eco2); }
[data-cat="measure"] > .dot, .dot[data-cat="measure"] { background: var(--c-measure); }
[data-cat="academic"] > .dot, .dot[data-cat="academic"] { background: var(--c-academic); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px 1px 6px; border-radius: 6px; background: var(--surface-2); color: var(--text); font-size: 12px; font-weight: 600; line-height: 20px; white-space: nowrap; }

/* 목록 */
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.list-head { display: none; }
.row { display: grid; gap: 6px 16px; padding: 14px 16px; border-top: 1px solid var(--border); }
.list > .row:first-of-type, .list-head + .row { border-top: 0; }
.row[hidden] { display: none; }
body:not(.show-closed) .list-bids .row[data-closed="1"] { display: none; }
.c-cat { grid-area: cat; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.c-main { grid-area: main; min-width: 0; }
.c-amt { grid-area: amt; font-variant-numeric: tabular-nums; }
.c-due { grid-area: due; display: flex; flex-direction: column; align-items: flex-end; gap: 1px; text-align: right; }
.c-corp { grid-area: corp; min-width: 0; font-size: 14px; }

.title { color: var(--text); text-decoration: none; font-weight: 600; line-height: 1.45; }
a.title:hover { color: var(--link-hover); text-decoration: underline; text-underline-offset: 2px; }
.title .ext { margin-left: 4px; color: var(--text-3); font-size: 12px; font-weight: 400; }
.meta { display: flex; flex-wrap: wrap; align-items: center; margin-top: 3px; font-size: 13px; color: var(--text-2); }
.meta > span:not(:first-child)::before { content: "·"; margin: 0 6px; color: var(--text-3); }
.meta > span:has(> .tag)::before { content: ""; margin: 0 3px; }
.tag { display: inline-block; padding: 0 6px; border: 1px solid var(--border-strong); border-radius: 4px; font-size: 11px; line-height: 18px; color: var(--text-2); }
.row[data-closed="1"] .title { color: var(--text-3); }

.c-amt b { font-weight: 600; }
.c-amt .lbl { margin-right: 4px; font-size: 12px; color: var(--text-3); }
.c-amt .sub { display: block; font-size: 12px; color: var(--text-3); }
.dday { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dday::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); }
.dday[data-lvl="critical"]::before { background: var(--st-critical); }
.dday[data-lvl="serious"]::before { background: var(--st-serious); }
.dday[data-lvl="closed"] { color: var(--text-3); font-weight: 600; }
.when { font-size: 12px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }

.kind { display: inline-flex; padding: 1px 8px; border-radius: 6px; border: 1px solid var(--border-strong); font-size: 12px; font-weight: 600; line-height: 20px; white-space: nowrap; color: var(--text); }
.kind[data-kind="award"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.kind[data-kind="opening"] { border-style: dashed; }
.c-corp b { font-weight: 600; }
.members { display: block; margin-top: 1px; font-size: 12px; color: var(--text-2); }

/* 휴대폰: 카드형 */
.list-bids .row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "cat due" "main main" "amt amt"; }
.list-bids .c-amt .sub { display: inline; margin-left: 8px; }
.list-radar .row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "cat due" "main main" "corp corp" "amt amt"; }
.list-radar .c-amt .sub { display: inline; margin-left: 8px; }

/* PC: 표형 */
@media (min-width: 860px) {
  .list-head { display: grid; gap: 16px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); font-size: 12px; font-weight: 600; color: var(--text-2); }
  .list-head .r { text-align: right; }
  .list-bids .row, .list-bids .list-head { grid-template-columns: 76px minmax(0, 1fr) 120px 120px; grid-template-areas: "cat main amt due"; align-items: center; }
  .list-radar .row, .list-radar .list-head { grid-template-columns: 112px minmax(0, 1fr) minmax(0, 220px) 112px 80px; grid-template-areas: "cat main corp amt due"; align-items: center; }
  .c-cat { flex-direction: column; align-items: flex-start; }
  .c-amt { text-align: right; }
  .list-bids .c-amt .sub, .list-radar .c-amt .sub { display: block; margin-left: 0; }
}

.row.is-first { border-top: 0; }
.more { display: block; width: 100%; margin-top: 8px; height: 44px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.more:hover { border-color: var(--border-strong); }
.more[hidden] { display: none; }
.loading { color: var(--text-2); }
.empty { margin: 0; padding: 40px 16px; text-align: center; color: var(--text-3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }

/* 상단 메뉴 */
.topnav { display: flex; gap: 2px; margin-right: auto; margin-left: 8px; }
.topnav a { padding: 6px 10px; border-radius: 6px; color: var(--text-2); font-size: 14px; font-weight: 500; text-decoration: none; }
.topnav a:hover { background: var(--surface-2); color: var(--text); }
@media (max-width: 560px) {
  .topnav { order: 3; width: 100%; margin: 0 0 0 -10px; }
}

/* 목록 안의 기관·업체 링크 */
.sub-link, a.corp { color: inherit; text-decoration: none; }
.sub-link:hover, a.corp:hover { color: var(--link-hover); text-decoration: underline; }
.related h2 .all { margin-left: 8px; font-size: 13px; font-weight: 500; color: var(--text-2); text-decoration: none; }
.related h2 .all:hover { color: var(--link-hover); text-decoration: underline; }
.related h2 .muted { font-size: 13px; font-weight: 500; }

/* 기관·업체 페이지 */
.entity .lead .pill { margin-left: 2px; }
.entity .stats { margin: 20px 0 4px; }
.entity .stat .value { font-size: 24px; }
.related ul.toplist { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; background: none; border: 0; border-radius: 0; }
.related ul.toplist li { padding: 6px 12px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); font-size: 14px; line-height: 1.4; }
.toplist a { color: var(--text); font-weight: 600; text-decoration: none; }
.toplist a:hover { color: var(--link-hover); text-decoration: underline; }
.related li .pill { margin-right: 4px; vertical-align: 1px; }
.related li[hidden] { display: none; }
.dir-search { margin: 16px 0 0; }
.dir-search input { width: 100%; max-width: 360px; }

/* 목록의 원문 링크 */
.meta .src { color: var(--text-3); text-decoration: none; }
.meta .src:hover { color: var(--link-hover); text-decoration: underline; }

/* 상세 페이지 */
.detail { max-width: 860px; padding-top: 16px; padding-bottom: 8px; }
.crumbs { font-size: 13px; color: var(--text-3); margin-bottom: 12px; }
.crumbs a { color: var(--text-2); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.detail .c-cat { flex-direction: row; margin-bottom: 8px; }
.detail h1 { margin: 0 0 4px; font-size: 24px; line-height: 1.35; letter-spacing: -0.03em; font-weight: 700; }
.detail .lead { margin: 0; color: var(--text-2); font-size: 15px; }
.detail .actions { margin: 16px 0 0; }
.btn { display: inline-flex; align-items: center; height: 40px; padding: 0 16px; border-radius: 8px; background: var(--text); color: var(--bg); font-size: 14px; font-weight: 600; text-decoration: none; }
.btn:hover { opacity: 0.88; }
.detail section { margin-top: 28px; }
.detail h2 { margin: 0 0 10px; font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.facts dl { display: grid; grid-template-columns: 1fr; margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.facts dt { padding: 10px 16px 0; font-size: 12px; color: var(--text-3); }
.facts dd { margin: 0; padding: 2px 16px 10px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.facts dd:last-child { border-bottom: 0; }
@media (min-width: 640px) {
  .facts dl { grid-template-columns: 140px minmax(0, 1fr); }
  .facts dt { padding: 11px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); font-size: 13px; color: var(--text-2); }
  .facts dd { padding: 11px 16px; }
  .facts dt:nth-last-of-type(1) { border-bottom: 0; }
}
.facts .dday { margin-left: 8px; font-size: 13px; }
.muted { color: var(--text-3); font-weight: 400; }
.timeline ol { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--border); margin-left: 6px; }
.timeline li { position: relative; display: grid; grid-template-columns: 1fr; gap: 2px; padding: 0 0 18px 18px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); }
.timeline li[data-kind="award"]::before, .timeline li[data-kind="contract"]::before { background: var(--text); border-color: var(--text); }
.timeline li:last-child { padding-bottom: 0; }
.timeline .when { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.timeline .step { display: block; margin-bottom: 2px; font-size: 15px; }
.timeline .what { font-size: 14px; color: var(--text-2); }
.timeline .what b { color: var(--text); }
.timeline a { color: var(--text-2); }
.related ul { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.related li { padding: 11px 16px; border-top: 1px solid var(--border); font-size: 14px; line-height: 1.5; }
.related li:first-child { border-top: 0; }
.related a { color: var(--text); font-weight: 600; text-decoration: none; }
.related a:hover { color: var(--link-hover); text-decoration: underline; }
.detail .note { margin-top: 28px; font-size: 12px; color: var(--text-3); }

.notfound { padding: 80px 16px; text-align: center; }
.notfound h1 { margin: 0 0 8px; font-size: 22px; }
.notfound p { color: var(--text-2); }

.foot { margin-top: 48px; padding: 24px 0 48px; border-top: 1px solid var(--border); color: var(--text-3); font-size: 13px; }
.foot p { margin: 0 0 6px; max-width: 760px; }
