/* 3D 견적 맛보기 — home.css 의 브랜드 토큰(body.portal-home 의 --color-*)을 쓰고, 없으면 같은 값으로 폴백한다.
   블록은 남색 배경(.p-estimate-feature) 안에 들어가므로 자체 흰 카드로 그린다. 모든 선택자는 .ex-estimate 로 시작한다. */
.ex-estimate{--ex-primary:var(--color-primary,#1E88E5);--ex-primary-text:var(--color-primary-text,#1565C0);--ex-soft:var(--color-primary-soft,#E3F2FD);--ex-ink:var(--color-text-heading,#16243A);--ex-muted:var(--color-text-muted,#64748B);--ex-line:var(--color-border,#E2E8F0);--ex-surface:var(--color-surface,#FFFFFF);--ex-neutral:var(--color-surface-neutral,#F1F5F9);--ex-warn:var(--color-warning-text,#B45309);
  background:var(--ex-surface);color:var(--ex-ink);border-radius:18px;padding:26px;margin:4px 0 22px;font-size:14px;line-height:1.6;box-shadow:0 12px 32px var(--color-shadow-soft,#16243A15)}
.ex-estimate *{box-sizing:border-box}
.ex-estimate [hidden]{display:none!important}
.ex-estimate p{margin:0}
.ex-estimate button{font:inherit;color:inherit;cursor:pointer}
.ex-estimate button:disabled{cursor:default;opacity:.55}
.ex-estimate :focus-visible{outline:3px solid var(--ex-primary-text);outline-offset:3px}
.ex-estimate code{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:.92em;letter-spacing:.01em}
.ex-estimate-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}

/* 머리 */
.ex-estimate-top{display:flex;justify-content:space-between;align-items:flex-end;gap:20px;margin-bottom:18px}
.ex-estimate-eyebrow{font-size:11px;font-weight:700;letter-spacing:.14em;color:var(--ex-primary-text);display:flex;align-items:center;gap:10px;margin-bottom:8px!important}
.ex-estimate-chip{display:inline-block;border:1px solid var(--ex-line);background:var(--ex-neutral);color:var(--ex-primary-text);font-size:10px;font-weight:650;letter-spacing:0;border-radius:4px;padding:3px 8px;white-space:nowrap;vertical-align:middle}
.ex-estimate-lead{font-size:clamp(18px,2vw,23px);font-weight:750;letter-spacing:-.04em;line-height:1.4;color:var(--ex-ink)}
.ex-estimate-caption{font-size:11px;color:var(--ex-muted);max-width:360px;text-align:right;line-height:1.7}

/* 무대: 3D + 부위 목록 */
.ex-estimate-stage{display:grid;grid-template-columns:minmax(0,1.45fr) minmax(260px,1fr);gap:18px;align-items:stretch}
.ex-estimate-viewer{position:relative;min-height:340px;border-radius:14px;overflow:hidden;background:linear-gradient(180deg,#f3f6fa 0%,#dde5ee 100%);border:1px solid var(--ex-line)}
.ex-estimate-canvas-host{position:absolute;inset:0}
.ex-estimate-canvas-host canvas{display:block;width:100%!important;height:100%!important;touch-action:pan-y;cursor:grab;outline:0}
.ex-estimate-canvas-host canvas.is-hover{cursor:pointer}
.ex-estimate-canvas-host canvas.is-dragging{cursor:grabbing}
.ex-estimate-poster{position:absolute;inset:0;z-index:2;display:flex;align-items:flex-end}
.ex-estimate-poster img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;object-position:left center;opacity:.55;filter:saturate(.6)}
.ex-estimate-poster-copy{position:relative;width:100%;padding:18px;background:linear-gradient(180deg,rgba(255,255,255,0) 0%,rgba(255,255,255,.92) 45%);display:flex;flex-wrap:wrap;gap:12px;align-items:center;justify-content:space-between}
.ex-estimate-poster-copy p{font-size:13px;color:var(--ex-ink);font-weight:600}
.ex-estimate .ex-estimate-poster-copy button{min-height:44px;padding:10px 16px;border-radius:8px;border:1px solid var(--ex-primary-text);background:var(--ex-primary-text);color:var(--color-on-primary,#fff);font-weight:650;font-size:13px}
.ex-estimate[data-demo-state=ready] .ex-estimate-poster{display:none}
.ex-estimate[data-demo-state=fallback] .ex-estimate-poster img{opacity:.9;filter:none}
.ex-estimate-active{position:absolute;top:14px;right:14px;z-index:3;background:var(--ex-primary);color:#fff;font-size:12px;font-weight:650;padding:7px 14px;border-radius:999px;box-shadow:0 2px 8px rgba(0,0,0,.15);pointer-events:none;max-width:calc(100% - 28px);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ex-estimate-tools{position:absolute;right:12px;bottom:12px;z-index:3;display:flex;gap:6px}
.ex-estimate-tools button{min-width:44px;min-height:44px;display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:0 12px;border-radius:9px;border:1px solid var(--ex-line);background:rgba(255,255,255,.92);color:var(--ex-ink);font-size:12px;font-weight:650;box-shadow:0 2px 6px rgba(0,0,0,.08)}
.ex-estimate-tools button:hover{background:#fff;border-color:var(--ex-primary)}
.ex-estimate-tools svg{width:18px;height:18px}
.ex-estimate-hint{position:absolute;left:12px;bottom:14px;z-index:3;font-size:11px;color:var(--ex-muted);background:rgba(255,255,255,.78);padding:4px 9px;border-radius:6px;pointer-events:none}

/* 부위 목록 */
.ex-estimate-parts{display:flex;flex-direction:column;min-width:0}
.ex-estimate-parts-title{font-size:13px;font-weight:700;margin-bottom:10px!important;display:flex;flex-direction:column;gap:2px}
.ex-estimate-parts-title span{font-size:11px;font-weight:500;color:var(--ex-muted)}
.ex-estimate-part-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px;overflow:auto;max-height:560px;padding:2px;scrollbar-width:thin}
.ex-estimate-part-list button{display:flex;flex-direction:column;align-items:flex-start;gap:2px;min-height:52px;padding:8px 12px;border-radius:9px;border:1px solid var(--ex-line);background:var(--ex-surface);text-align:left;line-height:1.35;transition:border-color .12s,background .12s}
.ex-estimate-part-list button span{font-size:13px;font-weight:650}
.ex-estimate-part-list button small{font-size:10px;color:var(--ex-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
.ex-estimate-part-list button:hover:not(:disabled){border-color:var(--ex-primary)}
.ex-estimate-part-list button[aria-pressed=true]{background:var(--ex-soft);border-color:var(--ex-primary);color:var(--ex-primary-text)}
.ex-estimate-part-list button[aria-pressed=true] small{color:var(--ex-primary-text)}
.ex-estimate-part-list button.is-active{box-shadow:inset 0 0 0 1px var(--ex-primary)}

/* 담긴 항목 */
.ex-estimate-sheet{margin-top:18px;border-top:1px solid var(--ex-line);padding-top:18px}
.ex-estimate-sheet-head{display:flex;justify-content:space-between;align-items:baseline;gap:16px;margin-bottom:10px}
.ex-estimate-sheet-head p{font-size:13px;font-weight:700;display:flex;align-items:center;gap:8px}
.ex-estimate-sum{color:var(--ex-muted);font-weight:600}
.ex-estimate-sum strong{font-size:22px;color:var(--ex-ink);letter-spacing:-.03em;margin-left:6px}
.ex-estimate-table-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch}
.ex-estimate table{width:100%;border-collapse:collapse;font-size:13px;min-width:560px}
.ex-estimate thead th{font-size:11px;font-weight:650;color:var(--ex-muted);text-align:left;padding:6px 8px;border-bottom:1px solid var(--ex-line);white-space:nowrap}
.ex-estimate tbody th,.ex-estimate tbody td{padding:9px 8px;border-bottom:1px solid var(--ex-neutral);vertical-align:top;text-align:left;font-weight:500}
.ex-estimate tbody th{font-weight:700;white-space:nowrap}
.ex-estimate-code small{display:block;font-size:10px;color:var(--ex-muted);margin-top:2px}
.ex-estimate-nocode{font-size:11px;color:var(--ex-warn)}
.ex-estimate-num{text-align:right!important;white-space:nowrap;font-variant-numeric:tabular-nums}
.ex-estimate-empty{font-size:13px;color:var(--ex-muted);padding:16px 0;text-align:center;border:1px dashed var(--ex-line);border-radius:9px}
.ex-estimate-actions{display:flex;flex-wrap:wrap;align-items:center;gap:10px 16px;margin-top:16px}
.ex-estimate-button{min-height:46px;display:inline-flex;align-items:center;gap:9px;padding:10px 18px;border-radius:8px;border:1px solid var(--ex-line);background:var(--ex-surface);font-size:13px;font-weight:650;transition:background .15s}
.ex-estimate-button:hover:not(:disabled){background:var(--ex-soft)}
.ex-estimate-button svg{width:18px;height:18px}
/* .ex-estimate button{color:inherit} 보다 구체적으로 써야 흰 글자가 이긴다. */
.ex-estimate .ex-estimate-button-primary{background:var(--ex-primary-text);border-color:var(--ex-primary-text);color:var(--color-on-primary,#fff)}
.ex-estimate .ex-estimate-button-primary:hover:not(:disabled){background:var(--ex-primary)}
.ex-estimate-link{display:inline-flex;align-items:center;gap:10px;font-size:13px;font-weight:650;color:var(--ex-primary-text);margin-left:auto;text-decoration:none}
.ex-estimate-link svg{width:16px;height:16px}
.ex-estimate-link:hover{text-decoration:underline}
.ex-estimate-note{font-size:11px;color:var(--ex-muted);margin-top:14px!important;line-height:1.7}

/* 예시 견적서 미리보기 (인쇄 대상) */
.ex-estimate-print{margin-top:20px;border:1px solid var(--ex-line);border-radius:12px;padding:26px 28px;background:#fff;color:#111;font-size:13px;line-height:1.6;overflow-x:auto}
.ex-estimate-print:focus{outline:0}
.ex-estimate-print-head{display:flex;justify-content:space-between;gap:20px;align-items:flex-start;border-bottom:2px solid #111;padding-bottom:14px;margin-bottom:14px}
.ex-estimate-print-kicker{font-size:10px;letter-spacing:.16em;color:#555;margin-bottom:6px!important}
.ex-estimate-print h4{font-size:24px;margin:0;letter-spacing:.2em;font-weight:800}
.ex-estimate-print dl{margin:0}
.ex-estimate-print dl div{display:flex;gap:10px;font-size:12px}
.ex-estimate-print dt{color:#666;min-width:64px}
.ex-estimate-print dd{margin:0;font-weight:600}
.ex-estimate-print-meta{display:grid;gap:3px;text-align:left}
.ex-estimate-print-vehicle{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:4px 24px;margin-bottom:16px}
.ex-estimate-print-table{min-width:0!important;font-size:12px}
.ex-estimate-print-table th,.ex-estimate-print-table td{border-bottom:1px solid #ddd!important;padding:7px 6px!important;color:#111!important}
.ex-estimate-print-table thead th{border-bottom:1px solid #111!important;background:#f4f4f4}
.ex-estimate-print-table td small{display:block;font-size:10px;color:#666}
.ex-estimate-print-table tfoot th{text-align:right;font-weight:600;color:#444!important}
.ex-estimate-print-total th,.ex-estimate-print-total td{font-size:15px;font-weight:800;border-top:2px solid #111;color:#111!important}
.ex-estimate-print-empty{text-align:center;color:#777;padding:18px!important}
.ex-estimate-print-memo{margin-top:16px!important;font-size:11px;color:#444;border:1px dashed #bbb;padding:10px 12px;border-radius:6px}
.ex-estimate-print-foot{margin-top:18px;font-size:10px;color:#777;text-align:center;letter-spacing:.04em}

@media (max-width:900px){
  .ex-estimate{padding:20px}
  .ex-estimate-top{flex-direction:column;align-items:flex-start;gap:8px}
  .ex-estimate-caption{text-align:left;max-width:none}
  .ex-estimate-stage{grid-template-columns:1fr;gap:12px}
  .ex-estimate-viewer{min-height:0;aspect-ratio:4/3}
  .ex-estimate-part-list{display:flex;gap:8px;max-height:none;overflow-x:auto;padding:2px 2px 8px;scroll-snap-type:x proximity}
  .ex-estimate-part-list button{flex:0 0 auto;min-height:44px;scroll-snap-align:start;max-width:200px}
}
@media (max-width:600px){
  .ex-estimate{padding:16px 14px;border-radius:14px}
  .ex-estimate-lead{font-size:17px}
  .ex-estimate-tools button span{display:none}
  .ex-estimate-tools button{padding:0;width:44px}
  .ex-estimate-hint{display:none}
  .ex-estimate-viewer{aspect-ratio:auto;height:280px}
  .ex-estimate-sum strong{font-size:19px}
  .ex-estimate-actions{gap:8px}
  .ex-estimate-button{font-size:12px;padding:9px 13px;min-height:44px}
  .ex-estimate-link{margin-left:0;width:100%;justify-content:center;min-height:44px}
  .ex-estimate-print{padding:18px 14px}
  .ex-estimate-print-head{flex-direction:column;gap:10px}
  .ex-estimate-print-vehicle{grid-template-columns:1fr}
}
@media (prefers-reduced-motion:reduce){
  .ex-estimate *{transition:none!important}
}

/* 인쇄: '예시 견적 확인' 뒤 '인쇄창 열기'를 누르면 스크립트가 body 에 ex-estimate-printing 을 붙인다.
   미리보기(#ex-estimate-preview)만 종이에 남기고 나머지는 숨긴다. :has 미지원 브라우저는 visibility 규칙만으로 동작한다. */
@media print{
  body.ex-estimate-printing{visibility:hidden;background:#fff;height:auto!important;margin:0!important}
  body.ex-estimate-printing #ex-estimate-preview,body.ex-estimate-printing #ex-estimate-preview *{visibility:visible}
  body.ex-estimate-printing #ex-estimate-preview{display:block!important;position:absolute;left:0;top:0;width:100%;margin:0;border:0;border-radius:0;padding:12mm 10mm;box-shadow:none}
  /* :has 지원 브라우저(Chrome/Edge/Safari/Firefox 121+): 미리보기의 조상 경로만 남기고 전부 display:none → 빈 페이지 0장 */
  @supports selector(:has(a)){
    body.ex-estimate-printing *:not(:has(#ex-estimate-preview)):not(#ex-estimate-preview):not(#ex-estimate-preview *){display:none!important}
    body.ex-estimate-printing :has(#ex-estimate-preview){display:block!important;height:auto!important;min-height:0!important;padding:0!important;margin:0!important;border:0!important;box-shadow:none!important;background:#fff!important;position:static!important;overflow:visible!important}
    body.ex-estimate-printing #ex-estimate-preview{position:static;overflow:visible}
  }
  .ex-estimate-print-table{page-break-inside:auto}
  .ex-estimate-print-table tr{page-break-inside:avoid}
}
