/*
 * 현장제안 평가 화면 스타일. 색·간격·글꼴은 .harness/DESIGN.md 토큰을 따른다. (공통 컴포넌트는 .harness/assets/dsr-ui 사용)
 * © 2026 DSR, DSR Wire. All rights reserved. Made by 이서하\user.
 */
:root {
  --color-primary: #1c3b7b;
  --color-primary-hover: #142d5f;
  --color-primary-soft: #e8eef8;
  --color-background: #f6f8fb;
  --color-surface: #ffffff;
  --color-text: #172033;
  --color-text-muted: #5f6b7a;
  --color-border: #d8dee8;
  --color-success: #18794e;
  --color-warning: #a15c00;
  --color-danger: #c62828;
  --color-focus: #4c78d0;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-6: 24px; --space-8: 32px;
  --radius-sm: 6px; --radius-md: 10px; --radius-lg: 14px;
  --purple: #5b3fb5;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--color-background); color: var(--color-text); line-height: 1.5;
  font: 15px/1.5 Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", Arial, sans-serif; }
a { color: var(--color-primary); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--color-focus) 45%, transparent); outline-offset: 2px; }
.wrap { max-width: 900px; margin: 0 auto; padding: var(--space-6) var(--space-4); }
.wrap.wide { max-width: 1400px; }
.wrap.evalwrap { max-width: 1180px; }
h1 { font-size: 28px; font-weight: 700; margin: 0; }
h2 { font-size: 20px; font-weight: 700; margin: 0 0 var(--space-3); }
h3 { font-size: 16px; font-weight: 600; margin: 0 0 var(--space-2); }
.muted { color: var(--color-text-muted); font-size: 14px; }
.pre-line { white-space: pre-line; margin: 0; }
.dsr-logo { display: block; width: auto; height: 36px; object-fit: contain; }
.brand { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); }
.brand-name { font-weight: 600; color: var(--color-text-muted); }
header.top { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-4); }
header.top h1 { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
/* 툴팁을 버튼 아래쪽에 표시 (기본은 위쪽) */
.dsr-tooltip.tip-below .dsr-tooltip__content { bottom: auto; top: calc(100% + 8px); left: auto; right: 0; max-width: 280px; transform: translateY(-4px); }
.dsr-tooltip.tip-below:hover .dsr-tooltip__content, .dsr-tooltip.tip-below:focus-within .dsr-tooltip__content { transform: translateY(0); }
.dsr-tooltip[hidden] { display: none; }
.actions, .btnrow { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; }
.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 20px; margin-bottom: var(--space-4); }
.card > h2:first-child { margin-top: 0; }

/* 안내·상태 */
.notice { display: flex; gap: var(--space-2); align-items: flex-start; border: 1px solid var(--color-border); border-left-width: 4px; border-radius: var(--radius-sm); background: var(--color-surface); padding: 10px 14px; margin-bottom: var(--space-3); }
.notice.warn { border-left-color: var(--color-warning); background: #fff8ec; }
.notice.info { border-left-color: var(--color-primary); background: var(--color-primary-soft); }
.notice.err { border-left-color: var(--color-danger); background: #fff1f1; }
.notice .lucide, .badge .lucide { width: 16px; height: 16px; flex: none; margin-top: 3px; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text); white-space: nowrap; }
.badge .lucide { margin-top: 0; width: 14px; height: 14px; }
.b-ok { color: var(--color-success); border-color: var(--color-success); }
.b-warn { color: var(--color-warning); border-color: var(--color-warning); }
.b-bad { color: var(--color-danger); border-color: var(--color-danger); }
.loading { color: var(--color-text-muted); padding: var(--space-6) 0; display: flex; gap: var(--space-2); align-items: center; }
.empty { text-align: center; color: var(--color-text-muted); padding: var(--space-6) 0; }

/* 폼 */
label.lbl { display: block; font-weight: 600; margin: var(--space-3) 0 var(--space-1); }
.field-row { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
input.dsr-input, select.dsr-select { min-width: 0; }
.dsr-button .lucide { flex: none; }
.dsr-button.sm { min-height: 32px; padding: 0 10px; font-size: 14px; }
.dsr-button.sm .lucide { width: 16px; height: 16px; }
.dsr-button.big { min-height: 44px; }
.dsr-button[aria-busy="true"] { cursor: progress; }
.deadline { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--color-border); }
.deadline input[type=date] { width: auto; }
.deadline-note { margin-top: var(--space-2); }
.deadline-note.late b { color: var(--color-danger); }
.inl { display: flex; align-items: center; gap: var(--space-2); font-weight: 400; margin: 0; }
.inl input { width: auto; }

/* 표 */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { border-bottom: 1px solid var(--color-border); padding: 8px 6px; text-align: left; vertical-align: middle; }
th { color: var(--color-text-muted); font-size: 13px; font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.eqtbl { table-layout: fixed; }
table.eqtbl th, table.eqtbl td { width: 25%; padding: 8px 12px; overflow-wrap: anywhere; }
table.eqtbl th { background: var(--color-background); border-bottom: 2px solid var(--color-border); }
table.proptbl td { white-space: nowrap; }
table.proptbl td:nth-child(5) { white-space: normal; min-width: 240px; }
details.fold > summary { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); cursor: pointer; list-style: none; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary h2 { margin: 0; }
details.fold > summary::after { content: "펼치기"; font-size: 14px; color: var(--color-primary); border: 1px solid var(--color-primary); border-radius: var(--radius-sm); padding: 3px 12px; }
details.fold[open] > summary::after { content: "접기"; }
details.fold[open] > summary { margin-bottom: var(--space-2); }
dialog.dlg { width: min(760px, 92vw); max-height: 86vh; overflow: auto; border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 18px 20px; background: var(--color-surface); color: var(--color-text); box-shadow: 0 12px 40px rgba(23, 32, 51, .3); }
dialog.dlg::backdrop { background: rgba(23, 32, 51, .5); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); }
.dlg h3 { margin: 6px 0 4px; font-size: 18px; }

/* 제안 내용 카드 */
.part { border: 1px solid color-mix(in srgb, var(--bar) 45%, transparent); border-radius: var(--radius-sm); padding: 10px 14px; background: var(--color-surface); }
.part h4 { margin: 0 0 4px; font-size: 13px; font-weight: 700; color: var(--bar); }
.part p { margin: 0; white-space: pre-wrap; line-height: 1.75; }
.part.before { --bar: var(--color-warning); }
.part.after { --bar: var(--color-success); }
.part.whole { --bar: var(--color-text-muted); }
.stack { margin: 10px 0; }
.stack .part { border-left: 5px solid var(--bar); }
.stack .join { text-align: center; color: var(--color-text-muted); line-height: 1.2; margin: 3px 0; }
.side { display: grid; grid-template-columns: minmax(0, 1fr) 30px minmax(0, 1fr); align-items: stretch; margin-bottom: var(--space-4); }
.side .part { border-top: 5px solid var(--bar); }
.side .join { display: flex; align-items: center; justify-content: center; color: var(--color-text-muted); }
.side.single { display: block; }

/* 평가 화면 */
.evalgrid { display: grid; grid-template-columns: 176px minmax(0, 1fr); gap: 18px; align-items: start; }
.toc { position: sticky; top: 12px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 10px; max-height: calc(100vh - 28px); overflow: auto; }
.toc-h { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.toc-h .muted { font-weight: 400; font-size: 12px; }
.toc-g { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.tocb { padding: 5px 0; font: inherit; font-size: 13px; background: transparent; color: var(--color-text); border: 1px solid var(--color-border); border-radius: var(--radius-sm); cursor: pointer; }
.tocb:hover { border-color: var(--color-primary); background: var(--color-primary-soft); }
.tocb.done { background: var(--color-success); border-color: var(--color-success); color: #fff; }
.tocb.cur { outline: 2px solid var(--color-primary); outline-offset: 1px; }
.toc-l { font-size: 12px; color: var(--color-text-muted); margin-top: 8px; line-height: 1.8; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; border: 1px solid var(--color-border); vertical-align: -1px; }
.dot.done { background: var(--color-success); border-color: var(--color-success); }
.sticky { position: sticky; top: 0; z-index: 5; background: var(--color-background); padding: 8px 0; }
.bar { height: 8px; background: var(--color-border); border-radius: 9px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--color-success); transition: width .2s; }
.ctl { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.legend { font-size: 14px; color: var(--color-text-muted); }
.prop h3 { margin: 2px 0 4px; font-size: 16px; }
.prop .meta { color: var(--color-text-muted); font-size: 14px; }
.prop .meta .who { color: var(--color-text); font-weight: 700; }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--space-2); }
.scale button { font: inherit; background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 8px 2px; line-height: 1.25; cursor: pointer; }
.scale button b { display: block; font-size: 19px; }
.scale button small { font-size: 12px; color: var(--color-text-muted); }
.scale button:not(:disabled):hover { background: var(--color-primary-soft); border-color: var(--color-primary); }
.scale button.sel { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.scale button.sel small { color: #fff; }
.scale button:disabled { opacity: .55; cursor: not-allowed; }
.save { font-size: 13px; color: var(--color-text-muted); min-height: 1.3em; margin-top: 4px; }

/* 회의 화면 */
.meet { display: grid; grid-template-columns: 380px 1fr; gap: 14px; align-items: stretch; margin-bottom: var(--space-4); }
.meet > .card { margin-bottom: 0; }
.list { position: relative; padding: 0; overflow: hidden; min-height: 420px; }
.list .listin { position: absolute; inset: 0; padding: 10px; overflow: auto; }
.filters { display: flex; gap: 6px; margin-bottom: var(--space-2); }
.item { display: grid; grid-template-columns: 42px 1fr 44px 56px; gap: 6px; align-items: center; width: 100%; text-align: left; font: inherit; background: transparent; color: var(--color-text); border: 1px solid transparent; border-bottom-color: var(--color-border); border-radius: var(--radius-sm); padding: 8px 6px; cursor: pointer; }
.item:hover { background: var(--color-primary-soft); }
.item.on { background: var(--color-primary-soft); border-color: var(--color-primary); }
.item .rk { color: var(--color-text-muted); font-size: 13px; }
.item .tt { font-size: 14px; line-height: 1.35; }
.item .av { font-weight: 700; text-align: right; }
.item .gr, table.rt .gr { font-size: 13px; text-align: center; border: 1px solid var(--color-success); color: var(--color-success); border-radius: 99px; padding: 1px 0; font-weight: 600; }
.item .gr.none, table.rt .gr.none { border-color: var(--color-border); color: var(--color-text-muted); }
.flag { color: var(--color-warning); vertical-align: middle; }
.flag .lucide { width: 14px; height: 14px; }
.detail { min-height: max(78vh, 840px); }
.detail h2 { font-size: 20px; margin: 4px 0 8px; }
.detail .meta { color: var(--color-text-muted); font-size: 14px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.big-score { margin: 4px 0 10px; }
.big-score b { font-size: 24px; }
.scoretbl { max-width: 260px; }
.scoretbl td { padding: 4px 6px; }
.sc { font-weight: 700; }
.sc.none { color: var(--color-text-muted); font-weight: 400; }
.grades { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--space-2); margin-bottom: var(--space-3); }
.imps { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-2); }
.grades .g, .imps .g { font: inherit; font-size: 14px; background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 6px 2px; text-align: center; white-space: nowrap; cursor: pointer; }
.imps .g { padding: 6px 16px; }
.grades .g:not(:disabled):hover, .imps .g:not(:disabled):hover { background: var(--color-primary-soft); border-color: var(--color-primary); }
.grades .g.sel, .imps .g.sel { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.grades .g:disabled, .imps .g:disabled { opacity: .55; cursor: not-allowed; }
.chips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.chip { border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 6px 12px; min-width: 0; display: flex; align-items: baseline; gap: 4px 8px; flex-wrap: wrap; }
.chip .muted { margin-left: auto; font-size: 12px; }
.chip .cnt { font-weight: 700; color: var(--purple); }
.chip.warn { border-color: var(--color-warning); }
.chip.warn .cnt { color: var(--color-warning); }
#summary { padding: 12px 16px; }
.sums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 10px; }
.sumitem { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; border-left: 3px solid var(--color-border); padding: 2px 10px; }
.sumitem b { font-size: 16px; }
.sumitem small { flex-basis: 100%; font-size: 12px; color: var(--color-text-muted); }
.sumitem:last-child { border-left-color: var(--color-primary); }
.sumitem:last-child b { color: var(--color-primary); }
.awform { margin-top: 12px; padding: 12px; background: var(--color-background); border-radius: var(--radius-sm); }
.awrow { display: grid; grid-template-columns: 1.2fr 1.4fr 130px 1.6fr auto; gap: 10px; align-items: center; }
.awcustom { display: grid; grid-template-columns: 1fr 2fr; gap: var(--space-2); margin-top: var(--space-2); }
.awdesc { margin-top: var(--space-2); min-height: 1.2em; }
.awlist { margin-top: 12px; }
.awlist dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 8px 0 0; }
.awlist dt { font-weight: 700; }
.awlist dd { margin: 0; color: var(--color-text-muted); }
.awtbl th, .awtbl td { text-align: left; border-right: 1px solid var(--color-border); }
.awtbl th:last-child, .awtbl td:last-child { border-right: 0; text-align: center; width: 56px; }
.awtbl th { background: var(--color-background); border-bottom: 2px solid var(--color-border); white-space: nowrap; }
.awtbl td.amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.awrow input.amt { text-align: left; font-variant-numeric: tabular-nums; }
tr.tot td { font-weight: 700; background: var(--color-background); }
.icon-del { display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid color-mix(in srgb, var(--color-danger) 55%, transparent); border-radius: 50%; background: transparent; color: var(--color-danger); cursor: pointer; }
.icon-del:hover:not(:disabled) { background: #fff1f1; border-color: var(--color-danger); }
.icon-del:disabled { opacity: .5; cursor: not-allowed; }
.icon-del .lucide { width: 16px; height: 16px; }
.memo-box { width: 100%; }

/* 최종 집계 */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: var(--space-4); }
.tile { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.tile b { font-size: 24px; }
.tile small { font-size: 13px; color: var(--color-text-muted); }
.tile.total { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.tile.total small, .tile.total span { color: #dbe7ff; }
table.rt th, table.rt td { text-align: center; padding: 8px; white-space: nowrap; }
table.rt th { background: var(--color-background); border-bottom: 2px solid var(--color-border); }
table.rt th.l, table.rt td.l { text-align: left; }
table.rt td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.rt td.memo { white-space: normal; min-width: 200px; max-width: 360px; }
table.rt tr.price td { color: var(--color-text-muted); font-size: 13px; background: var(--color-background); }
table.rt .gr { display: inline-block; min-width: 56px; padding: 1px 8px; }

@media (max-width: 900px) {
  .sums, .tiles { grid-template-columns: repeat(2, 1fr); }
  .awrow { grid-template-columns: 1fr; }
  .meet { grid-template-columns: 1fr; }
  .two { grid-template-columns: 1fr; }
  .list { min-height: 0; }
  .list .listin { position: static; max-height: 40vh; }
  .evalgrid { grid-template-columns: 1fr; }
  .toc { position: static; max-height: none; }
  .toc-g { grid-template-columns: repeat(8, 1fr); }
  .chips { grid-template-columns: repeat(2, 1fr); }
  .side { grid-template-columns: 1fr; }
  .side .join { padding: 4px 0; }
  .detail { min-height: 0; }
}
@media (max-width: 520px) {
  .wrap { padding: var(--space-3) var(--space-4); }
  .dsr-toast-container { right: 16px; bottom: 16px; }
}
@media (prefers-reduced-motion: reduce) { .bar i { transition: none; } }
