:root {
      color-scheme: light;
      --bg: #f5f7fb;
      --surface: #ffffff;
      --surface-2: #f0f4f8;
      --surface-3: #e7edf5;
      --ink: #17202f;
      --muted: #667085;
      --line: #d9e1ec;
      --line-strong: #b8c4d4;
      --brand: #1f4e79;
      --brand-2: #1f837f;
      --good: #2f8b57;
      --warn: #d9852b;
      --danger: #c24848;
      --purple: #6f5bb7;
      --shadow: 0 14px 38px rgba(27, 39, 61, .11);
      --radius: 8px;
      --panel-gap: 14px;
      --nav-w: 236px;
      --top-h: 68px;
      --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", sans-serif;
    }
    [data-theme="dark"] {
      color-scheme: dark;
      --bg: #10151d;
      --surface: #161d28;
      --surface-2: #1d2633;
      --surface-3: #263244;
      --ink: #eef3fa;
      --muted: #9ba8ba;
      --line: #2e3b50;
      --line-strong: #47566c;
      --brand: #7db9f3;
      --brand-2: #5fd3c8;
      --good: #62c987;
      --warn: #f0b35e;
      --danger: #f07676;
      --purple: #b59cff;
      --shadow: 0 16px 46px rgba(0,0,0,.32);
    }
    * { box-sizing: border-box; }
    html { scroll-behavior: smooth; }
    body {
      margin: 0;
      background: var(--bg);
      color: var(--ink);
      font-family: var(--font);
      letter-spacing: 0;
    }
    button, input, textarea, select { font: inherit; }
    button { cursor: pointer; }
    .app-shell {
      min-height: 100vh;
      display: grid;
      grid-template-columns: var(--nav-w) minmax(0, 1fr);
    }
    .side-nav {
      position: sticky;
      top: 0;
      height: 100vh;
      padding: 18px 14px;
      background: var(--surface);
      border-right: 1px solid var(--line);
      display: flex;
      flex-direction: column;
      gap: 18px;
      z-index: 10;
    }
    .brand-lockup { display: grid; gap: 8px; padding: 4px 6px 8px; }
    .brand-row { display: flex; align-items: center; gap: 10px; }
    .brand-mark {
      width: 36px; height: 36px; border-radius: 8px;
      background: linear-gradient(135deg, var(--brand), var(--brand-2));
      color: white; display: grid; place-items: center;
      font-weight: 800; letter-spacing: 0;
    }
    .brand-name { font-size: 19px; font-weight: 800; line-height: 1; }
    .brand-sub { color: var(--muted); font-size: 12px; line-height: 1.35; }
    .nav-section { display: grid; gap: 6px; }
    .nav-link {
      text-decoration: none;
      color: var(--muted);
      display: flex;
      gap: 10px;
      align-items: center;
      padding: 9px 10px;
      border-radius: 8px;
      border: 1px solid transparent;
      font-size: 13px;
    }
    .nav-link.active, .nav-link:hover {
      color: var(--ink);
      background: var(--surface-2);
      border-color: var(--line);
    }
    .nav-link svg, .icon-btn svg, .btn svg { width: 16px; height: 16px; flex: 0 0 auto; }
    .nav-footer {
      margin-top: auto;
      border-top: 1px solid var(--line);
      padding-top: 14px;
      display: grid;
      gap: 10px;
    }
    .status-pill {
      display: flex; align-items: center; justify-content: space-between; gap: 8px;
      color: var(--muted); background: var(--surface-2);
      border: 1px solid var(--line); padding: 8px 10px; border-radius: 8px;
      font-size: 12px;
    }
    .status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
    .status-dot.ready { background: var(--good); box-shadow: 0 0 0 4px color-mix(in srgb, var(--good) 18%, transparent); }
    .status-dot.running { background: var(--warn); animation: pulse 1s infinite; }
    .status-dot.idle { background: var(--line-strong); }
    .main {
      min-width: 0;
      display: grid;
      grid-template-rows: var(--top-h) 1fr;
    }
    .topbar {
      position: sticky; top: 0; z-index: 9;
      height: var(--top-h);
      display: flex; align-items: center; justify-content: space-between; gap: 14px;
      padding: 12px 20px;
      background: color-mix(in srgb, var(--bg) 88%, transparent);
      backdrop-filter: blur(14px);
      border-bottom: 1px solid var(--line);
    }
    .top-title { display: grid; gap: 2px; min-width: 0; }
    .top-title strong { font-size: 15px; }
    .top-title span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .top-actions { display: flex; gap: 8px; align-items: center; }
    .btn, .icon-btn, .tab-btn {
      border: 1px solid var(--line);
      background: var(--surface);
      color: var(--ink);
      border-radius: 8px;
      min-height: 34px;
      padding: 8px 11px;
      display: inline-flex;
      align-items: center;
      gap: 7px;
      font-weight: 650;
      font-size: 12px;
    }
    .btn.primary {
      background: linear-gradient(135deg, var(--brand), var(--brand-2));
      color: white;
      border-color: transparent;
      box-shadow: 0 12px 22px color-mix(in srgb, var(--brand) 20%, transparent);
    }
    .btn.ghost { background: transparent; }
    .icon-btn { width: 36px; height: 36px; padding: 0; justify-content: center; }
    .content {
      width: 100%;
      max-width: 1640px;
      margin: 0 auto;
      padding: 18px 20px 48px;
      display: grid;
      gap: var(--panel-gap);
    }
    .section { scroll-margin-top: calc(var(--top-h) + 14px); }
    .hero-grid {
      display: grid;
      grid-template-columns: minmax(340px, 430px) minmax(0, 1fr) minmax(310px, 400px);
      gap: var(--panel-gap);
      align-items: stretch;
    }
    .panel {
      background: var(--surface);
      border: 1px solid var(--line);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      min-width: 0;
    }
    .panel.pad { padding: 14px; }
    .panel-header {
      padding: 13px 14px;
      border-bottom: 1px solid var(--line);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
    }
    .panel-title { display: grid; gap: 3px; }
    .panel-title h2, .panel-title h3 { margin: 0; font-size: 15px; line-height: 1.2; }
    .panel-title p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.35; }
    .input-stack { display: grid; gap: 12px; }
    .field { display: grid; gap: 7px; }
    .field label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
    textarea, input[type="text"], select {
      width: 100%;
      border: 1px solid var(--line);
      background: var(--surface-2);
      color: var(--ink);
      border-radius: 8px;
      padding: 10px 11px;
      outline: none;
    }
    textarea { min-height: 172px; resize: vertical; line-height: 1.5; }
    textarea:focus, input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent); }
    .upload-box {
      border: 1px dashed var(--line-strong);
      border-radius: 8px;
      padding: 12px;
      background: var(--surface-2);
      display: grid;
      gap: 9px;
    }
    .file-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; min-width: 0; }
    .file-name { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
    .chip {
      padding: 5px 8px;
      background: var(--surface-2);
      border: 1px solid var(--line);
      border-radius: 999px;
      color: var(--muted);
      font-size: 11px;
      white-space: nowrap;
    }
    .chip.hot { color: var(--ink); border-color: color-mix(in srgb, var(--brand) 48%, var(--line)); background: color-mix(in srgb, var(--brand) 12%, var(--surface)); }
    .pipeline {
      display: grid;
      grid-template-columns: repeat(6, 1fr);
      gap: 8px;
      padding: 14px;
    }
    .step {
      min-height: 90px;
      border: 1px solid var(--line);
      background: var(--surface-2);
      border-radius: 8px;
      padding: 10px;
      display: grid;
      align-content: start;
      gap: 6px;
      position: relative;
      overflow: hidden;
    }
    .step::before {
      content: "";
      position: absolute;
      inset: 0;
      transform: translateX(-115%);
      background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--brand) 18%, transparent), transparent);
    }
    .step.running::before { animation: scan 1.1s ease-in-out infinite; }
    .step.done { border-color: color-mix(in srgb, var(--good) 52%, var(--line)); background: color-mix(in srgb, var(--good) 8%, var(--surface)); }
    .step strong { font-size: 12px; }
    .step span { color: var(--muted); font-size: 11px; line-height: 1.35; }
    .decision-card {
      padding: 14px;
      display: grid;
      gap: 12px;
    }
    .decision-badge {
      height: 88px;
      border-radius: 8px;
      display: grid;
      place-items: center;
      background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 16%, var(--surface)), color-mix(in srgb, var(--brand-2) 12%, var(--surface)));
      border: 1px solid color-mix(in srgb, var(--brand) 28%, var(--line));
      text-align: center;
    }
    .decision-badge b { font-size: 34px; line-height: 1; }
    .decision-badge span { color: var(--muted); font-size: 12px; }
    .kpi-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 8px;
    }
    .kpi {
      border: 1px solid var(--line);
      background: var(--surface-2);
      border-radius: 8px;
      padding: 10px;
      min-height: 72px;
      display: grid;
      gap: 5px;
    }
    .kpi span { color: var(--muted); font-size: 11px; }
    .kpi b { font-size: 22px; }
    .kpi small { color: var(--muted); font-size: 11px; }
    .map-section {
      display: grid;
      grid-template-columns: minmax(0, 1fr) minmax(330px, 430px);
      gap: var(--panel-gap);
      min-height: 620px;
    }
    .map-wrap {
      position: relative;
      height: 580px;
      padding: 12px;
    }
    #marketCanvas { width: 100%; height: 100%; display: block; border-radius: 8px; background: var(--surface); }
    .map-lock {
      position: absolute; inset: 12px;
      border-radius: 8px;
      display: grid; place-items: center;
      background: color-mix(in srgb, var(--surface) 74%, transparent);
      backdrop-filter: blur(10px);
      border: 1px solid var(--line);
      text-align: center;
      padding: 28px;
      transition: opacity .35s ease, transform .35s ease, pointer-events .35s ease;
    }
    .map-lock.hidden { opacity: 0; pointer-events: none; transform: scale(.98); }
    .map-lock .lock-inner { max-width: 430px; display: grid; gap: 10px; justify-items: center; }
    .pulse-orbit {
      width: 80px; height: 80px; border-radius: 50%;
      border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--line));
      position: relative;
      display: grid; place-items: center;
      color: var(--brand);
      animation: breathe 2.2s ease-in-out infinite;
    }
    .inspector {
      display: grid;
      grid-template-rows: auto auto minmax(0, 1fr);
      min-height: 580px;
    }
    .score-bars { display: grid; gap: 9px; padding: 14px; border-bottom: 1px solid var(--line); }
    .bar-row { display: grid; gap: 5px; }
    .bar-top { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
    .bar { height: 9px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
    .bar > i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .55s ease; }
    .bar.good > i { background: var(--good); }
    .bar.warn > i { background: var(--warn); }
    .bar.danger > i { background: var(--danger); }
    .inspector-body { padding: 14px; overflow: auto; display: grid; gap: 12px; }
    .memo-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
    .memo-list li { border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: var(--surface-2); font-size: 12px; line-height: 1.45; }
    .tabs-shell {
      display: grid;
      grid-template-rows: auto minmax(360px, auto);
      min-height: 460px;
    }
    .tabs {
      display: flex;
      gap: 6px;
      padding: 10px;
      border-bottom: 1px solid var(--line);
      overflow-x: auto;
    }
    .tab-btn { white-space: nowrap; background: transparent; color: var(--muted); box-shadow: none; }
    .tab-btn.active { color: var(--ink); background: var(--surface-2); border-color: var(--line-strong); }
    .tab-content { padding: 14px; }
    .grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--panel-gap); }
    .grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--panel-gap); }
    .mini-card { border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: 12px; display: grid; gap: 8px; min-width: 0; }
    .mini-card h4 { margin: 0; font-size: 13px; }
    .mini-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
    .data-table {
      width: 100%;
      border-collapse: collapse;
      font-size: 12px;
      overflow: hidden;
      border-radius: 8px;
    }
    .data-table th, .data-table td {
      border-bottom: 1px solid var(--line);
      padding: 9px 8px;
      text-align: left;
      vertical-align: top;
    }
    .data-table th { color: var(--muted); background: var(--surface-2); font-weight: 750; }
    .data-table tr:hover td { background: color-mix(in srgb, var(--brand) 6%, transparent); }
    .score-pill {
      display: inline-flex; align-items: center; justify-content: center;
      min-width: 48px; padding: 4px 7px; border-radius: 999px;
      background: var(--surface-3); border: 1px solid var(--line); font-variant-numeric: tabular-nums;
    }
    .drawer-backdrop {
      position: fixed; inset: 0; background: rgba(0,0,0,.28); z-index: 50;
      opacity: 0; pointer-events: none; transition: opacity .2s ease;
    }
    .drawer-backdrop.open { opacity: 1; pointer-events: auto; }
    .drawer {
      position: fixed; top: 0; right: 0; height: 100vh; width: min(680px, 92vw);
      background: var(--surface); border-left: 1px solid var(--line);
      z-index: 51; transform: translateX(103%); transition: transform .25s ease;
      box-shadow: -20px 0 60px rgba(0,0,0,.18);
      display: grid; grid-template-rows: auto minmax(0, 1fr);
    }
    .drawer.open { transform: translateX(0); }
    .drawer-body { padding: 16px; overflow: auto; display: grid; gap: 14px; }
    .modal-backdrop {
      position: fixed; inset: 0; z-index: 60; display: none; place-items: center;
      background: rgba(0,0,0,.28); padding: 20px;
    }
    .modal-backdrop.open { display: grid; }
    .modal { width: min(640px, 96vw); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
    .formula-body { padding: 15px; display: grid; gap: 11px; color: var(--muted); font-size: 13px; line-height: 1.55; }
    .formula-body code { color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 5px; }
    .canvas-card { height: 300px; position: relative; }
    .canvas-card canvas { width: 100%; height: 100%; display: block; }
    .source-note { font-size: 11px; color: var(--muted); line-height: 1.45; }
    .sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
    @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
    @keyframes scan { to { transform: translateX(115%); } }
    @keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
    @media (max-width: 1180px) {
      :root { --nav-w: 0px; }
      .app-shell { grid-template-columns: 1fr; }
      .side-nav { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
      .nav-section { grid-template-columns: repeat(4, minmax(0, 1fr)); }
      .content { width: 100%; }
      .hero-grid, .map-section { grid-template-columns: 1fr; }
      .inspector { min-height: 0; }
    }
    @media (min-width: 1181px) and (max-width: 1500px) {
      .hero-grid {
        grid-template-columns: minmax(340px, 1fr) minmax(360px, 1fr);
      }
      .hero-grid > .decision-card {
        grid-column: 1 / -1;
        grid-template-columns: minmax(240px, 320px) minmax(320px, 1fr) minmax(320px, 1fr);
        align-items: stretch;
      }
      .hero-grid > .decision-card .panel-title { grid-column: 1 / -1; }
      .hero-grid > .decision-card .decision-badge { height: auto; }
      .hero-grid > .decision-card .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
      .pipeline { grid-template-columns: repeat(3, minmax(0, 1fr)); }
      .map-section { grid-template-columns: minmax(0, 1fr) minmax(320px, 380px); }
    }
    @media (max-width: 720px) {
      .topbar { height: auto; align-items: flex-start; flex-direction: column; }
      .top-actions { flex-wrap: wrap; }
      .pipeline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .grid-2, .grid-3, .kpi-grid { grid-template-columns: 1fr; }
      .map-wrap { height: 460px; }
      .nav-section { grid-template-columns: 1fr 1fr; }
    }

    /* ── Phase 1 추가 스타일 ─────────────────────────────── */
    .engine-badge {
      display: inline-flex; align-items: center; gap: 6px;
      padding: 5px 10px; border-radius: 999px;
      font-size: 11.5px; font-weight: 700; letter-spacing: -.01em;
      border: 1px solid var(--line); white-space: nowrap;
    }
    .engine-badge::before {
      content: ""; width: 7px; height: 7px; border-radius: 50%;
      background: var(--warn); flex: none;
    }
    .engine-badge.live { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, var(--line)); }
    .engine-badge.live::before { background: var(--good); }
    .engine-badge.sim { color: var(--muted); background: var(--surface-2); }

    .asof-bar {
      display: flex; align-items: center; gap: 8px;
      padding: 9px 12px; margin-bottom: 12px;
      background: var(--surface-2); border: 1px solid var(--line);
      border-radius: var(--radius); color: var(--muted); font-size: 12px;
    }
    .asof-bar b { color: var(--ink); }
    .asof-bar svg { width: 14px; height: 14px; flex: none; }

    /* ── 심사 리포트 인쇄 ────────────────────────────────── */
    #printRoot { display: none; }
    @media print {
      .app-shell, .drawer, .drawer-backdrop, .modal-backdrop { display: none !important; }
      #printRoot { display: block !important; }
      @page { size: A4; margin: 14mm; }
      body { background: #fff; }
    }
    .pr-doc {
      color: #111; font-family: var(--font); font-size: 10.5pt; line-height: 1.55;
      background: #fff; max-width: 190mm;
    }
    .pr-head {
      display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
      border-bottom: 2px solid #111; padding-bottom: 8px; margin-bottom: 14px;
    }
    .pr-brand { font-size: 9pt; letter-spacing: .04em; color: #555; text-transform: uppercase; }
    .pr-head h1 { margin: 4px 0 0; font-size: 17pt; letter-spacing: -.02em; }
    .pr-meta { font-size: 8.5pt; color: #555; text-align: right; line-height: 1.6; }
    .pr-doc h2 {
      font-size: 11.5pt; margin: 16px 0 7px; padding-bottom: 3px;
      border-bottom: 1px solid #ccc; break-after: avoid;
    }
    .pr-verdict {
      display: flex; align-items: baseline; gap: 12px;
      padding: 9px 12px; border-radius: 6px; border: 1px solid #ccc; background: #f6f6f4;
    }
    .pr-verdict b { font-size: 15pt; letter-spacing: -.02em; }
    .pr-verdict span { font-size: 9.5pt; color: #444; }
    .pr-go     { border-left: 5px solid #0ca30c; }
    .pr-revise { border-left: 5px solid #d9852b; }
    .pr-hold   { border-left: 5px solid #c24848; }
    .pr-thesis { margin: 9px 0 0; }
    .pr-table { width: 100%; border-collapse: collapse; margin-top: 6px; break-inside: avoid; }
    .pr-table th, .pr-table td {
      border: 1px solid #d6d6d0; padding: 6px 9px; text-align: left;
      vertical-align: top; font-size: 9.5pt;
    }
    .pr-table th { background: #f2f2ef; font-weight: 700; width: 22%; }
    .pr-table thead th { width: auto; text-align: center; }
    .pr-scores td.pr-num { text-align: right; font-variant-numeric: tabular-nums; width: 60px; font-weight: 700; }
    .pr-bar { display: block; height: 9px; background: #e8e8e3; border-radius: 3px; overflow: hidden; }
    .pr-bar i { display: block; height: 100%; background: #2a78d6; border-radius: 3px; }
    .pr-list { margin: 6px 0 0; padding-left: 20px; }
    .pr-list li { margin-bottom: 5px; break-inside: avoid; }
    .pr-note { font-size: 8.5pt; color: #666; margin-top: 6px; }
    .pr-foot {
      margin-top: 18px; padding-top: 9px; border-top: 1px solid #ccc;
      font-size: 8.5pt; color: #555; line-height: 1.6; break-inside: avoid;
    }
