/* IBM Carbon 토큰 — 브랜드 색은 cretop-brand.js가 :root에 주입(--brand 계열) */
:root {
  --bg: #f4f4f4;
  --panel: #ffffff;
  --line: #e0e0e0;
  --text: #161616;
  --muted: #525252;
  --primary: var(--brand, #04b7c4);
  --primary-soft: var(--brand-50, #e2f7f9);
  --pass: #198038;   --pass-bg: #defbe6;
  --fail: #da1e28;   --fail-bg: #fff1f1;
  --unk: #684e00;    --unk-bg: #fff8e1;
  --radius: 0;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: Pretendard, -apple-system, "Malgun Gothic", sans-serif; font-size: 14px; line-height: 1.5;
}
button, input, select, textarea { font: inherit; color: inherit; }

/* 상단 */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 24px 32px; background: #161616; border: 1px solid #161616;
  width: calc(100% - 40px); max-width: 1240px; box-sizing: border-box;
  margin: 24px auto 0; color: #ffffff;
}
.topbar .btn.ghost { background: transparent; color: #ffffff; border-color: rgba(255,255,255,.32); }
.topbar .btn.ghost:hover { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.55); }
.brand { display: flex; gap: 10px; align-items: center; }
/* 제목+소개글 블록(42px) 높이에 맞춘 마크 */
.logo { width: 42px; height: 42px; display: block; object-fit: contain; }
.title { font-weight: 400; font-size: 22px; line-height: 27px; letter-spacing: 0; color: #ffffff; }
.sub { color: #c6c6c6; font-size: 12px; letter-spacing: 0.16px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

.btn { border: 1px solid var(--primary); background: var(--primary); color: #fff; border-radius: 0;
  padding: 7px 12px; cursor: pointer; font-weight: 600; font-size: 13px; }
.btn.ghost { background: #fff; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.file { position: relative; overflow: hidden; }
.btn.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* 2단 배치 */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 16px;
  padding: 16px 20px; max-width: 1280px; margin: 0 auto; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.result-panel { position: sticky; top: 60px; max-height: calc(100vh - 76px); overflow: auto; }
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; padding: 12px 16px; }
  .result-panel { position: static; max-height: none; }
  .topbar { padding: 16px; width: calc(100% - 32px); margin-top: 16px; }
}

/* 탭 */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; color: var(--muted);
  border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 600; }
.tabs button.on { color: var(--primary); border-bottom-color: var(--primary); }
.tabs .count { font-size: 11px; color: var(--muted); font-weight: 500; margin-left: 3px; }

/* 입력 */
.section-help { color: var(--muted); font-size: 13px; margin: -4px 0 12px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
@media (max-width: 560px) { .grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label { font-weight: 600; font-size: 13px; }
.field .help { color: var(--muted); font-size: 12px; }
.field .unit-wrap { display: flex; align-items: center; gap: 6px; }
.field .unit { color: var(--muted); font-size: 12px; white-space: nowrap; }
input[type=text], input[type=number], input[type=date], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 0; padding: 7px 9px; background: #fff; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
textarea { resize: vertical; min-height: 72px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 0; overflow: hidden; width: fit-content; }
.seg button { border: 0; background: #fff; padding: 6px 12px; cursor: pointer; font-size: 13px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--primary); color: #fff; }
.seg button.on.unk { background: #8d8d8d; }

/* 연구원 카드 */
.person { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.person-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; }
.person-head .name { font-weight: 700; }
.person .verdict { font-size: 12px; margin-top: 8px; }
.check-inline { display: flex; align-items: center; gap: 6px; font-size: 13px; }

/* 결과 요약 */
.summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
@media (max-width: 560px) { .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* 세로 flex + 상단 정렬: 카드 높이가 같아도 로고·배지는 항상 위에 고정, 설명글만 아래로 길어진다 */
.sum-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; cursor: pointer; background: #fff; text-align: left;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; }
.sum-card:hover { border-color: var(--primary); }
.sum-card .nm { font-weight: 700; font-size: 13px; line-height: 30px; }
/* 인증 로고 — 원본이 모두 높이 120px로 통일돼 있어 높이만 고정하면 4장이 같은 높이로 나온다 */
.sum-card .nm-logo { display: block; height: 30px; width: auto; max-width: 100%; object-fit: contain; object-position: left center; }
.sum-card .tr { color: var(--muted); font-size: 11px; margin-top: 4px; }

.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 0; margin-top: 6px; }
.pill.충족 { color: var(--pass); background: var(--pass-bg); }
.pill.미충족 { color: var(--fail); background: var(--fail-bg); }
.pill.확인필요 { color: var(--unk); background: var(--unk-bg); }

/* 판정 상세 */
.cert { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }
.cert > .head { padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: #f4f4f4; border-bottom: 1px solid var(--line); }
.cert > .head .nm { font-weight: 700; }
.cert .meta { font-size: 11px; color: var(--muted); padding: 6px 12px 0; }
details.track { border-top: 1px solid var(--line); }
details.track:first-of-type { border-top: 0; }
details.track > summary { padding: 9px 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; list-style: none; }
details.track > summary::-webkit-details-marker { display: none; }
details.track > summary::before { content: "▸"; color: var(--muted); margin-right: 6px; }
details.track[open] > summary::before { content: "▾"; }
details.track > summary .t { flex: 1; font-weight: 600; }
details.track > summary .pill { margin-top: 0; }
.chk { display: grid; grid-template-columns: 22px 1fr; gap: 6px; padding: 7px 12px 7px 14px; border-top: 1px dashed var(--line); }
.chk .ic { font-weight: 800; text-align: center; }
.chk .ic.충족 { color: var(--pass); } .chk .ic.미충족 { color: var(--fail); } .chk .ic.확인필요 { color: var(--unk); }
.chk .ct { font-weight: 600; }
.chk .rs { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.chk .fx { font-size: 13px; color: var(--primary); margin-top: 2px; }
.chk .src { font-size: 11px; color: #8d8d8d; margin-top: 2px; }

/* 로드맵 */
.step { display: grid; grid-template-columns: 30px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.step .no { width: 28px; height: 28px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-weight: 700; }
.step.ready .no { background: var(--pass-bg); color: var(--pass); }
.step .nm { font-weight: 700; }
.step ul { margin: 4px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.step .lbl { font-size: 12px; font-weight: 700; margin-top: 6px; }
.tip { background: var(--primary-soft); border-radius: 0; padding: 8px 10px; margin-top: 10px; font-size: 13px; }

/* 서류 */
.doc-group { margin-bottom: 16px; }
.doc-group h4 { margin: 0 0 6px; font-size: 14px; display: flex; justify-content: space-between; }
.doc-group h4 .count { color: var(--muted); font-weight: 500; font-size: 12px; }
.doc { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.doc input { margin-top: 3px; }
.doc .from { color: var(--muted); font-size: 12px; }
.doc.done .dn { text-decoration: line-through; color: var(--muted); }

/* 초안 */
.draft-controls { display: grid; gap: 10px; margin-bottom: 10px; }
pre.prompt { white-space: pre-wrap; background: #f4f4f4; border: 1px solid var(--line); border-radius: 0;
  padding: 12px; font-size: 12.5px; max-height: 420px; overflow: auto; overflow-wrap: anywhere; }
.note { font-size: 12px; color: var(--muted); }

/* 크레탑 업로드 */
#upload { margin-bottom: 14px; }
.drop { display: block; position: relative; border: 2px dashed #c6c6c6; border-radius: var(--radius); background: #fafafa;
  padding: 22px 16px; text-align: center; cursor: pointer; transition: background .15s, border-color .15s; }
.drop:hover, body.dragging .drop { background: var(--primary-soft); border-color: var(--primary); }
.drop input, .loaded input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.drop-ic { font-size: 26px; }
.drop-t { font-weight: 700; margin-top: 4px; }
.drop-s { color: var(--muted); font-size: 12px; margin-top: 4px; }
.loaded { position: relative; border: 1px solid #cfe0cf; background: #f5fbf6; border-radius: var(--radius); padding: 12px 14px; }
.loaded-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.loaded-t { font-weight: 700; overflow-wrap: anywhere; }
.loaded-s { font-size: 13px; margin-top: 2px; }
.muted { color: var(--muted); font-weight: 500; font-size: 12px; }
.warn { margin-top: 8px; font-size: 13px; color: var(--fail); background: var(--fail-bg); border-radius: 0; padding: 5px 9px; }
.remain { margin-top: 10px; font-size: 13px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { border: 1px solid #f1c21b; background: var(--unk-bg); color: #684e00; border-radius: 0; padding: 2px 10px; font-size: 12px; cursor: pointer; }
.chip b { margin-left: 2px; }
.est-note { color: var(--unk); font-size: 12px; }
#upload.busy { opacity: .6; pointer-events: none; }
.drop-overlay { display: none; position: fixed; inset: 0; background: rgba(37, 99, 235, .12); border: 3px dashed var(--primary);
  z-index: 50; place-items: center; font-size: 18px; font-weight: 700; color: var(--primary); pointer-events: none; }
body.dragging .drop-overlay { display: grid; }

/* 입력칸 상태 표시 */
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 700; border-radius: 0;
  padding: 1px 6px; margin-left: 6px; vertical-align: middle; }
.tag.src { color: var(--pass); background: var(--pass-bg); }
.tag.est { color: var(--unk); background: var(--unk-bg); }
.tag.need { color: var(--fail); background: var(--fail-bg); }
.tag-ok { border: 1px solid currentColor; background: #fff; color: inherit; border-radius: 0; font-size: 10px; padding: 0 4px; cursor: pointer; font-weight: 700; }
.field.need input, .field.need select, .field.need textarea, .field.need .seg { border-color: #f2a37c; background: #fffaf6; }
.field.est input, .field.est select, .field.est textarea { border-color: #f1c21b; background: #fffdf3; }
.field.src input, .field.src select, .field.src textarea { background: #f6fbf7; }
.help.srcnote { color: #6f6f6f; }
.need-box { border: 1px dashed #f2a37c; border-radius: var(--radius); background: #fffaf6; margin-bottom: 10px; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.tabs .count.need { background: var(--fail-bg); color: var(--fail); border-radius: 0; padding: 0 6px; font-weight: 700; margin-left: 5px; }
.tabs .count.ok { color: var(--pass); margin-left: 4px; }
.sum-card .held { color: var(--pass); font-weight: 700; }

[hidden] { display: none !important; }

/* 화면 전환(사전진단 / 사업계획서) */
.mode { display: flex; background: #e0e0e0; border-radius: 0; padding: 3px; gap: 2px; }
.mode button { border: 0; background: none; padding: 7px 14px; border-radius: 0; font-weight: 700; color: var(--muted); cursor: pointer; }
.mode button.on { background: #fff; color: var(--primary);  }

/* 사업계획서 작성 */
.plan-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; padding: 16px 20px; max-width: 1280px; margin: 0 auto; align-items: start; }
.plan-side { position: sticky; top: 124px; max-height: calc(100vh - 140px); overflow: auto; }
@media (max-width: 980px) {
  .plan-layout { grid-template-columns: 1fr; padding: 12px 16px; }
  .plan-side { position: static; max-height: none; }
}
.lbl { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.plan-pick { display: grid; gap: 6px; }
.plan-card { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 0; padding: 8px 10px; cursor: pointer; display: grid; gap: 4px; }
.plan-card.on { border-color: var(--primary); background: var(--primary-soft); }
.pc-name { font-weight: 700; font-size: 13px; }
.pc-bar { height: 4px; background: #e0e0e0; border-radius: 0; overflow: hidden; }
.pc-bar i { display: block; height: 100%; background: var(--pass); }
.pc-meta { font-size: 11px; color: var(--muted); }
.sec-list { display: grid; gap: 2px; }
.sec-item { display: grid; grid-template-columns: 10px 22px 1fr auto; gap: 6px; align-items: center; text-align: left; border: 0; background: none;
  padding: 7px 6px; border-radius: 0; cursor: pointer; font-size: 13px; }
.sec-item:hover { background: #f4f4f4; }
.sec-item.on { background: var(--primary-soft); }
.sec-item .dot { width: 8px; height: 8px; border-radius: 50%; background: #c6c6c6; }
.sec-item.done .dot { background: var(--pass); }
.sec-item.part .dot { background: #f1c21b; }
.sec-item.todo .dot { background: #f2a37c; }
.sec-item .sn { color: var(--muted); font-weight: 700; }
.sec-item .st { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sec-item .sm { font-size: 11px; color: var(--muted); white-space: nowrap; }
.sec-item.done .sm { color: var(--pass); font-weight: 700; }
.sec-item.todo .sm { color: var(--fail); }

.plan-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.plan-head h2 { margin: 0; font-size: 18px; }
.plan-overall { margin: 12px 0 8px; font-size: 13px; background: #f4f4f4; border: 1px solid var(--line); border-radius: 0; padding: 8px 12px; }
.warn-t { color: var(--fail); }
.plan-note { font-size: 13px; margin-bottom: 14px; }
.plan-note summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.plan-note p { margin: 6px 0; }
.sec-head { border-top: 1px solid var(--line); padding-top: 14px; }
.sec-head h3 { margin: 0 0 4px; font-size: 17px; }
.weight { font-size: 12px; color: #684e00; background: var(--unk-bg); display: inline-block; padding: 2px 8px; border-radius: 0; }
.guide { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; font-size: 13px; }
@media (max-width: 700px) { .guide { grid-template-columns: 1fr; } }
.guide > div { background: #f4f4f4; border: 1px solid var(--line); border-radius: 0; padding: 8px 10px; }
.guide b { display: block; font-size: 12px; margin-bottom: 3px; }
.guide ul { margin: 0; padding-left: 18px; }
.auto-wrap { margin: 8px 0; }
table.auto { border-collapse: collapse; width: 100%; font-size: 12.5px; margin-top: 4px; }
table.auto caption { text-align: left; font-weight: 700; font-size: 12px; margin-bottom: 3px; }
table.auto th, table.auto td { border: 1px solid var(--line); padding: 4px 7px; text-align: left; }
table.auto th { background: #f4f4f4; }
.auto-empty { font-size: 12.5px; color: var(--muted); }
.editor-help { font-size: 12px; margin: 10px 0 4px; }
#plan-text { width: 100%; min-height: 360px; font-size: 14px; line-height: 1.7; padding: 12px 14px; resize: vertical; overflow: hidden; }
.meter { margin-top: 8px; }
.meter-bar { position: relative; height: 8px; background: #e0e0e0; border-radius: 0; overflow: hidden; }
.meter-bar i { position: absolute; left: 0; top: 0; bottom: 0; background: #f2a37c; }
.meter.ok .meter-bar i { background: var(--pass); }
.meter.long .meter-bar i { background: #f1c21b; }
.meter-bar s { position: absolute; top: 0; bottom: 0; width: 2px; background: #161616; opacity: .35; }
.meter-t { font-size: 13px; margin-top: 4px; }
.meter.short .meter-t b:last-of-type { color: var(--fail); }
.meter.ok .meter-t b:last-of-type { color: var(--pass); }
.musts { margin-top: 10px; display: grid; gap: 3px; font-size: 13px; }
.must { color: var(--muted); }
.must.ok { color: var(--pass); font-weight: 600; }
.pwarn { margin-top: 8px; font-size: 13px; color: var(--fail); background: var(--fail-bg); border-radius: 0; padding: 5px 9px; }
.sec-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.sec-nav { display: flex; justify-content: space-between; gap: 8px; margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); }
.sec-nav .btn { max-width: 48%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.disclaimer { font-size: 11.5px; color: var(--muted); margin: 14px 0 0; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #161616; color: #fff;
  padding: 9px 16px; border-radius: 0; font-size: 13px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
.empty { color: var(--muted); padding: 20px 0; text-align: center; }

/* 허브 연동 상태줄 */
.hubline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; padding: 8px 12px; margin-bottom: 10px; border: 1px solid var(--line); background: #fff; }
.hubline.ok { border-color: var(--pass); background: var(--pass-bg); color: var(--pass); }
.hubline.diff { border-color: var(--primary); background: var(--primary-soft); }
.hubline.none { color: var(--muted); background: #f4f4f4; }
