/* ===== 토큰 ===== */
:root {
  --paper: #F2F4F3;
  --surface: #FFFFFF;
  --ink: #1A1F24;
  --muted: #66707A;
  --line: #D8DDDA;
  --line-soft: #E8EBE9;
  --board: #16191C;
  --led: #FFB31A;
  --led-off: rgba(255, 179, 26, .10);
  --link: #8F5300;
  --hover: #FFF6E3;
  --chip: #E6EAE8;
  --focus: #1F6FEB;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --dot: "Doto", var(--font);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121517;
    --surface: #1A1E21;
    --ink: #E9ECEA;
    --muted: #9AA3AA;
    --line: #2E3438;
    --line-soft: #252A2E;
    --board: #0B0D0F;
    --link: #FFC24D;
    --hover: #2A2516;
    --chip: #262B2F;
    --focus: #6EA8FF;
    color-scheme: dark;
  }
}

/* ===== 기본 ===== */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px 64px; }

/* ===== 상단 전광판 ===== */
.board {
  background-color: var(--board);
  background-image: radial-gradient(circle, rgba(255,255,255,.055) 1px, transparent 1.4px);
  background-size: 6px 6px;
  color: #EDEFF0;
}
.board-inner { max-width: 1180px; margin: 0 auto; padding: 36px 16px 0; }
.board-title { margin: 0; font-size: clamp(22px, 3.2vw, 30px); font-weight: 700; letter-spacing: -.02em; }
.board-range { margin: 4px 0 0; color: #9BA4AA; font-size: 14px; }

.board-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin-top: 28px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.stat { padding: 18px 0 20px; display: flex; flex-direction: column; gap: 2px; }
.stat + .stat { padding-left: 24px; border-left: 1px solid rgba(255,255,255,.08); }
.stat-num {
  font-family: var(--dot);
  font-weight: 900;
  font-size: clamp(34px, 6.4vw, 64px);
  line-height: 1;
  color: var(--led);
  text-shadow: 0 0 14px rgba(255, 179, 26, .45);
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}
.stat-label { font-size: 13px; color: #9BA4AA; }

.ticker {
  overflow: hidden;
  border-top: 1px solid rgba(255,255,255,.08);
  padding: 11px 0;
  mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
}
.ticker-track {
  display: inline-flex;
  gap: 48px;
  white-space: nowrap;
  color: var(--led);
  font-size: 14px;
  font-weight: 600;
  animation: ticker 90s linear infinite;
}
.ticker-track span b { font-weight: 800; margin-right: 8px; }
.ticker:hover .ticker-track { animation-play-state: paused; }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ===== 검색/필터 ===== */
.controls { margin-top: 28px; display: grid; gap: 12px; }
.search {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 14px;
  color: var(--muted);
}
.search:focus-within { border-color: var(--focus); }
.search input { flex: 1; border: 0; outline: 0; background: transparent; padding: 13px 0; color: var(--ink); font-size: 16px; }
.filter-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 0; cursor: pointer;
  background: var(--chip);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.chip small { opacity: .6; margin-left: 4px; }
select {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 14px;
}
.result-line { margin: 20px 0 8px; font-size: 14px; color: var(--muted); }
.result-line strong { color: var(--ink); font-weight: 700; }

/* ===== 목록 ===== */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.list { width: 100%; border-collapse: collapse; }
.list th {
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.list th.num, .list td.num { text-align: right; }
.sort { background: none; border: 0; padding: 0; cursor: pointer; color: inherit; font-weight: inherit; display: inline-flex; align-items: center; gap: 4px; }
.sort::after { content: "↕"; opacity: .35; font-size: 12px; }
.sort.is-active { color: var(--ink); }
.sort.is-active.asc::after { content: "↑"; opacity: 1; }
.sort.is-active.desc::after { content: "↓"; opacity: 1; }

.list td { padding: 14px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.list tbody tr:last-child td { border-bottom: 0; }
.list tbody tr { cursor: pointer; }
.list tbody tr:hover td { background: var(--hover); }
.c-vendor { font-weight: 600; min-width: 140px; }
.c-date { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.c-amount { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 700; }
.c-amount small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.c-name a {
  color: var(--link);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--link) 35%, transparent);
}
.c-name a:hover { text-decoration-color: currentColor; }
.c-name .org { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.c-method { white-space: nowrap; }
.tag { display: inline-block; font-size: 13px; padding: 2px 9px; border-radius: 6px; background: var(--chip); }
.tag.m-수의계약 { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.tag.m-일반경쟁 { background: #E3EEFF; color: #1E4FA8; }
.tag.m-제한경쟁 { background: #E6F4EA; color: #1E6B3A; }
.tag.m-지명경쟁 { background: #F4E8FA; color: #6A2C8C; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tag.m-일반경쟁 { background: #1D2B44; color: #9DC0FF; }
  :root:not([data-theme="light"]) .tag.m-제한경쟁 { background: #1B3226; color: #93D8AA; }
  :root:not([data-theme="light"]) .tag.m-지명경쟁 { background: #33233D; color: #D7A9F0; }
}
.none { color: var(--muted); font-weight: 400; font-style: normal; opacity: .75; }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.foot { margin-top: 20px; font-size: 13px; color: var(--muted); }

/* 모바일: 행을 카드처럼 */
@media (max-width: 760px) {
  .board-stats { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(3) { display: none; }
  .stat + .stat { padding-left: 16px; }
  .list thead { display: none; }
  .list, .list tbody, .list tr, .list td { display: block; width: 100%; }
  .list tr {
    padding: 14px 16px; border-bottom: 1px solid var(--line-soft);
    display: grid; grid-template-columns: 1fr auto; gap: 6px 12px;
    grid-template-areas: "name name" "vendor amount" "meta amount";
  }
  .list tbody tr:last-child { border-bottom: 0; }
  .list td { padding: 0; border: 0; }
  .list tbody tr:hover td { background: none; }
  .list tbody tr:hover { background: var(--hover); }
  .c-name { grid-area: name; font-size: 16px; }
  .c-vendor { grid-area: vendor; min-width: 0; }
  .list td.c-amount { grid-area: amount; text-align: right; align-self: center; }
  .c-date { grid-area: meta; font-size: 13px; align-self: center; }
  .c-method { grid-area: meta; justify-self: start; margin-left: 88px; }
  .c-method .tag { font-size: 12px; padding: 1px 8px; }
}

/* ===== 상세 패널 ===== */
.scrim { position: fixed; inset: 0; background: rgba(10, 12, 14, .45); z-index: 20; }
.sheet {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(620px, 100%);
  background: var(--surface);
  z-index: 21;
  display: flex; flex-direction: column;
  box-shadow: -24px 0 48px rgba(0,0,0,.18);
  animation: slideIn .22s ease-out;
}
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

.sheet-head { padding: 20px 24px 20px; border-bottom: 1px solid var(--line); }
.sheet-head-top { display: flex; justify-content: space-between; align-items: center; }
.sheet-no { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.close { border: 0; background: var(--chip); width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
.sheet-title { margin: 10px 0 16px; font-size: 21px; line-height: 1.4; letter-spacing: -.015em; }

.keyfacts { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px 20px; margin: 0; }
.keyfacts div { min-width: 0; }
.keyfacts dt { font-size: 12px; color: var(--muted); }
.keyfacts dd { margin: 0; font-weight: 700; font-size: 16px; }
.keyfacts .k-amount { grid-column: 1 / -1; }
.keyfacts .k-amount dd { font-size: 26px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.keyfacts .k-amount dd small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 8px; }

.sheet-body { flex: 1; overflow-y: auto; padding: 8px 24px 24px; overscroll-behavior: contain; }
.group h3 { margin: 22px 0 6px; font-size: 14px; font-weight: 700; color: var(--ink); }

/* 핵심: "컬럼명 ……… 값" 한 줄. 점선이 이름과 값을 이어 준다 */
.facts { margin: 0; }
.fact {
  display: flex; align-items: baseline; gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
}
.fact:last-child { border-bottom: 0; }
.fact dt { flex: none; max-width: 48%; font-size: 14px; color: var(--muted); }
.fact .leader {
  flex: 1 1 24px; min-width: 24px;
  align-self: center;
  height: 0;
  border-bottom: 2px dotted color-mix(in srgb, var(--muted) 45%, transparent);
  transform: translateY(3px);
}
.fact dd { margin: 0; flex: 0 1 auto; text-align: right; font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.fact dd small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }

/* 값이 긴 경우: 이름 아래로 값을 내림 */
.fact.long { display: block; }
.fact.long .leader { display: none; }
.fact.long dt { max-width: none; margin-bottom: 3px; }
.fact.long dd { text-align: left; font-weight: 600; line-height: 1.5; }

.fact.is-empty dd { font-weight: 400; color: var(--muted); }
.yn { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; }
.yn.y { background: #FFE7B3; color: #6B3E00; }
.yn.n { background: var(--chip); color: var(--muted); font-weight: 500; }

.sheet-foot { border-top: 1px solid var(--line); padding: 12px 24px; font-size: 14px; color: var(--muted); }
.toggle { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }

@media (max-width: 760px) {
  .sheet { width: 100%; top: auto; height: 92dvh; border-radius: 16px 16px 0 0; animation-name: slideUp; }
  @keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
  .sheet-head, .sheet-body, .sheet-foot { padding-left: 16px; padding-right: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .ticker-track { animation: none; }
  .sheet { animation: none; }
}
body.lock { overflow: hidden; }
