:root {
  --ink: #172235;
  --muted: #68758a;
  --line: #dce3ec;
  --line-strong: #c5d0de;
  --surface: #ffffff;
  --surface-soft: #f5f7fa;
  --navy: #173b68;
  --blue: #1769aa;
  --blue-soft: #eaf3fb;
  --green: #167557;
  --green-soft: #e7f5ef;
  --amber: #a86207;
  --amber-soft: #fff3dc;
  --red: #b33a3a;
  --red-soft: #fff0f0;
  --shadow: 0 12px 30px rgba(26, 47, 75, 0.08);
  font-family: Pretendard, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  color: var(--ink);
  background: #eef2f6;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 1080px; background: #f3f5f7; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.brand-block { display: flex; align-items: center; gap: 13px; }
.product-name { color: var(--navy); font-size: 18px; letter-spacing: -.03em; }
.brand-block > span { padding-left: 13px; border-left: 1px solid var(--line-strong); color: #536176; font-size: 13px; font-weight: 700; }
.eyebrow, .section-kicker { margin: 0; color: var(--blue); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.server-block { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.server-block div { display: grid; gap: 2px; }
.server-block div > span { display: none; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 0 4px rgba(104,117,138,.12); }
.status-dot.is-online { background: var(--green); box-shadow: 0 0 0 4px rgba(22,117,87,.12); }
.status-dot.is-offline { background: #9aa5b4; }
.status-dot.is-error { background: var(--red); box-shadow: 0 0 0 4px rgba(179,58,58,.12); }

.shell { min-height: calc(100vh - 58px); }
.workflow-nav { display: flex; gap: 0; margin-bottom: 18px; border-bottom: 1px solid var(--line-strong); }
.nav-item { border: 0; border-bottom: 3px solid transparent; padding: 12px 20px 10px; background: transparent; color: #6e7b8e; font-size: 12px; font-weight: 700; }
.nav-item:hover { color: var(--navy); }
.nav-item.is-active { border-bottom-color: var(--blue); color: var(--navy); }

.main { width: min(1500px, calc(100% - 56px)); margin: 0 auto; padding: 24px 0 50px; overflow: hidden; }
.deal-header { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 18px; }
.deal-header h2 { margin: 5px 0; font-size: 25px; letter-spacing: -.035em; }
.muted { margin: 0; color: var(--muted); font-size: 13px; }
.deal-fields { display: flex; align-items: end; gap: 10px; }
label { display: grid; gap: 6px; color: #556378; font-size: 11px; font-weight: 700; }
input, select { min-height: 38px; border: 1px solid var(--line-strong); border-radius: 5px; padding: 0 10px; background: #fff; color: var(--ink); outline: none; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23,105,170,.1); }
#dealName { width: 185px; }
#assetClass, #assetSubtype, #reviewStage { width: 135px; }

.stage-stepper { margin: 0 0 20px; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); list-style: none; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.stage-stepper li { position: relative; padding: 13px 18px 13px 46px; border-right: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.stage-stepper li:last-child { border-right: 0; }
.stage-stepper .stage-number { position: absolute; left: 16px; top: 12px; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: #e8edf3; font-size: 10px; font-weight: 800; }
.stage-stepper strong { display: block; color: inherit; margin-bottom: 3px; }
.stage-stepper li.is-complete { color: var(--green); background: #f7fcfa; }
.stage-stepper li.is-complete .stage-number { background: var(--green); color: #fff; }
.stage-stepper li.is-current { color: var(--navy); background: var(--blue-soft); }
.stage-stepper li.is-current .stage-number { background: var(--blue); color: #fff; }

.view { display: none; }
.view.is-active { display: block; }
.intake-panel { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 142px; margin-bottom: 16px; padding: 25px 28px; overflow: hidden; border: 1px dashed #8fb0cf; border-radius: 10px; background: linear-gradient(135deg, #f7fbff 0%, #edf5fc 100%); }
.intake-panel.has-files { min-height: 100px; border-style: solid; background: #fff; }
.intake-copy h3 { margin: 5px 0 7px; font-size: 20px; letter-spacing: -.025em; }
.intake-copy p:last-child { max-width: 700px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.intake-actions { display: flex; flex-shrink: 0; gap: 7px; }
.intake-progress { position: absolute; right: 0; bottom: 0; left: 0; height: 25px; overflow: hidden; background: #e7edf4; }
.intake-progress i { position: absolute; inset: 0 auto 0 0; width: 0; background: #cfe7f8; transition: width .2s ease; }
.intake-progress span { position: relative; z-index: 1; display: block; padding: 6px 12px; color: var(--navy); font-size: 9px; font-weight: 700; text-align: center; }
body:not(.has-case) .main { width: min(760px, calc(100% - 48px)); min-height: calc(100vh - 58px); display: grid; align-items: center; padding: 40px 0 90px; }
body:not(.has-case) .deal-header,
body:not(.has-case) .stage-stepper,
body:not(.has-case) .workflow-nav,
body:not(.has-case) .summary-grid,
body:not(.has-case) .content-grid { display: none; }
body:not(.has-case) #workspaceView { display: block; }
body:not(.has-case) .intake-panel { min-height: 330px; flex-direction: column; justify-content: center; padding: 48px; border-width: 2px; background: #fff; text-align: center; box-shadow: 0 18px 50px rgba(26,47,75,.08); }
body:not(.has-case) .intake-copy h3 { margin-top: 12px; font-size: 28px; }
body:not(.has-case) .intake-copy p:last-child { margin-top: 12px; font-size: 13px; }
body:not(.has-case) #addFilesButton,
body:not(.has-case) #saveJsonButton { display: none; }
body:not(.has-case) #chooseFolderButton { min-height: 46px; padding: 0 24px; font-size: 13px; }
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.summary-card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 15px 17px; box-shadow: 0 3px 12px rgba(26,47,75,.035); }
.summary-card span { display: block; color: var(--muted); font-size: 11px; font-weight: 700; }
.summary-card strong { display: block; margin: 7px 0 3px; font-size: 25px; }
.summary-card small { color: var(--muted); font-size: 10px; }
.summary-card.is-alert strong { color: var(--red); }

.content-grid { display: grid; grid-template-columns: minmax(720px, 1fr) 300px; gap: 14px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); overflow: hidden; }
.panel-heading { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.panel-heading.compact { min-height: 64px; }
.panel-heading h3 { margin: 4px 0 0; font-size: 16px; letter-spacing: -.02em; }
.heading-actions { display: flex; gap: 7px; }
.panel-description { margin: 0; padding: 13px 18px; color: var(--muted); background: var(--surface-soft); border-bottom: 1px solid var(--line); font-size: 11px; }
.button { min-height: 34px; border: 1px solid transparent; border-radius: 5px; padding: 0 13px; font-size: 11px; font-weight: 800; }
.button:disabled { cursor: not-allowed; opacity: .48; }
.button-primary { background: var(--blue); color: #fff; }
.button-primary:hover { background: #0d5b99; }
.button-secondary { border-color: #a9bfd5; background: #f7fbff; color: var(--navy); }
.button-quiet { border-color: var(--line); background: #fff; color: #536176; }

.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 12px; background: #f4f6f9; border-bottom: 1px solid var(--line); color: #5e6c80; font-size: 10px; text-align: left; white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid #e8edf3; font-size: 11px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfe; }
.document-title { display: grid; gap: 3px; }
.document-title strong { font-size: 12px; }
.document-title code { color: #758296; font-size: 9px; }
.file-open-button { display: grid; gap: 3px; max-width: 290px; border: 0; padding: 0; background: transparent; color: var(--ink); text-align: left; }
.file-open-button strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.file-open-button code { color: var(--blue); font-size: 9px; }
.file-open-button:hover strong { color: var(--blue); text-decoration: underline; }
.classification-select { width: 190px; min-height: 32px; font-size: 10px; }
.path-text { display: block; max-width: 340px; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.status-chip { display: inline-block; min-width: 45px; border-radius: 12px; padding: 4px 8px; font-size: 9px; font-weight: 800; text-align: center; }
.status-chip.required { background: var(--blue-soft); color: var(--blue); }
.status-chip.optional { background: var(--amber-soft); color: var(--amber); }
.status-chip.not-generated { background: #eef1f4; color: #7a8797; }
.file-control { display: flex; align-items: center; gap: 7px; max-width: 240px; }
.file-control input { display: none; }
.file-name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.file-label { border: 1px solid var(--line-strong); border-radius: 4px; padding: 6px 9px; color: var(--navy); background: #fff; cursor: pointer; white-space: nowrap; }
.process-state { color: var(--muted); white-space: nowrap; }
.process-state.success { color: var(--green); font-weight: 800; }
.process-state.review { color: var(--amber); font-weight: 800; }
.process-state.error { color: var(--red); font-weight: 800; }
.disabled-row { opacity: .55; background: #fafbfc; }

.count-badge { min-width: 25px; height: 25px; display: grid; place-items: center; border-radius: 13px; background: var(--red-soft); color: var(--red); font-size: 11px; font-weight: 800; }
.empty-state { padding: 38px 25px; color: var(--muted); text-align: center; }
.empty-state strong { color: #46556a; font-size: 12px; }
.empty-state p { margin: 7px auto 0; max-width: 260px; font-size: 11px; line-height: 1.6; }
.review-items { padding: 8px 14px 15px; display: grid; gap: 8px; }
.review-item { border-left: 3px solid var(--amber); padding: 9px 10px; background: #fffaf0; }
.review-item strong { display: block; font-size: 11px; }
.review-item span { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.45; }

.filter-row { display: flex; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.file-tabs { display: flex; gap: 4px; padding: 10px 14px 0; overflow-x: auto; border-bottom: 1px solid var(--line); background: #f7f9fb; scrollbar-width: thin; }
.file-tab { display: flex; align-items: center; flex: 0 0 auto; gap: 8px; max-width: 250px; min-height: 38px; border: 1px solid transparent; border-bottom: 0; border-radius: 6px 6px 0 0; padding: 0 12px; background: transparent; color: #66758a; font-size: 10px; }
.file-tab span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-tab small { min-width: 19px; border-radius: 10px; padding: 2px 5px; background: #e3e8ee; color: #657286; font-size: 8px; text-align: center; }
.file-tab.is-active { border-color: var(--line); background: #fff; color: var(--navy); font-weight: 800; transform: translateY(1px); }
.file-tab.is-active small { background: var(--blue-soft); color: var(--blue); }
.filter-row label:first-child { min-width: 260px; }
.observation-table { min-width: 1080px; }
.observation-table input { width: 130px; min-height: 32px; font-size: 11px; }
.observation-table input.value-input { width: 150px; text-align: right; }
.source-quote { display: block; max-width: 300px; color: #526176; line-height: 1.45; }
.source-doc { display: block; margin-bottom: 3px; color: var(--blue); font-size: 9px; font-weight: 800; }
.confidence { display: flex; align-items: center; gap: 7px; }
.confidence-bar { width: 55px; height: 5px; border-radius: 3px; background: #e4e9ef; overflow: hidden; }
.confidence-bar i { display: block; height: 100%; background: var(--green); }
.row-actions { display: flex; gap: 5px; }
.mini-button { border: 1px solid var(--line); border-radius: 4px; padding: 5px 7px; background: #fff; color: #526176; font-size: 9px; font-weight: 800; }
.mini-button.accept { border-color: #9fcdbd; color: var(--green); }

.calculator-layout { display: grid; grid-template-columns: minmax(560px, 1.15fr) minmax(420px, .85fr); gap: 14px; }
.calculator-inputs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 18px; }
.calculator-input { border: 1px solid var(--line); border-radius: 6px; padding: 12px; background: #fbfcfe; }
.calculator-input label { display: block; color: var(--ink); font-size: 11px; }
.calculator-input input { width: 100%; margin-top: 7px; text-align: right; background: #fff; }
.calculator-input small { display: block; margin-top: 5px; color: var(--muted); font-size: 9px; }
.metric-results { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); }
.metric-card { min-height: 115px; padding: 20px; background: #fff; }
.metric-card span { color: var(--muted); font-size: 10px; font-weight: 700; }
.metric-card strong { display: block; margin: 10px 0 4px; font-size: 24px; }
.metric-card small { color: var(--muted); font-size: 9px; }
.metric-card.review strong { color: var(--amber); }
.calculation-note { margin: 16px; border: 1px solid #f0d29d; background: var(--amber-soft); padding: 13px; }
.calculation-note strong { font-size: 11px; }
.calculation-note p { margin: 6px 0 0; color: #725225; font-size: 10px; line-height: 1.5; }

.audit-grid { grid-template-columns: 1fr 1fr; }
.conflict-items { padding: 14px; display: grid; gap: 10px; }
.conflict-item { border: 1px solid #efc3c3; border-radius: 6px; padding: 12px; background: #fff8f8; }
.conflict-item strong { font-size: 11px; color: var(--red); }
.conflict-values { display: grid; gap: 5px; margin-top: 8px; font-size: 10px; }
.audit-list { margin: 0; padding: 12px 20px 20px 42px; max-height: 570px; overflow: auto; }
.audit-list li { padding: 8px 0 10px 3px; border-bottom: 1px solid #edf0f4; font-size: 10px; line-height: 1.5; }
.audit-list time { display: block; color: var(--muted); font-size: 9px; }

dialog { width: 520px; border: 0; border-radius: 10px; padding: 0; box-shadow: 0 30px 80px rgba(14,30,50,.28); }
dialog::backdrop { background: rgba(14,30,50,.48); }
.dialog-card { padding-bottom: 18px; }
.dialog-card > label { margin: 14px 18px; }
.dialog-card input { width: 100%; }
.dialog-close { border: 0; background: transparent; color: var(--muted); font-size: 11px; }
.dialog-help { margin: 8px 18px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 7px; padding: 8px 18px 0; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: 380px; padding: 12px 16px; border-radius: 6px; background: #172b46; color: #fff; font-size: 11px; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-error { background: #8b2929; }

@media (max-width: 1250px) {
  .main { padding-left: 20px; padding-right: 20px; }
  .deal-header { align-items: start; }
  .deal-fields { display: grid; grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
  .review-panel { display: none; }
}
