:root {
  --bg: #f5f5f7; --card: #ffffff; --ink: #1d1d1f; --ink-2: #424245; --muted: #86868b; --line: #e5e5ea; --line-2: #d2d2d7;
  --dark: #1c1c1e; --accent: #0071e3; --accent-ink: #ffffff; --green: #30d158; --orange: #ff9f0a; --red: #ff3b30; --line-green: #06c755;
  --r-lg: 22px; --r: 14px; --r-sm: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.04);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button { font: inherit; cursor: pointer; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 640px; margin: 0 auto; padding: 0 16px; }

/* ---------- header ---------- */
.nav { position: sticky; top: 0; z-index: 20; background: rgba(245,245,247,.82); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid rgba(0,0,0,.06); }
.nav .wrap { display: flex; align-items: center; height: 56px; gap: 12px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.logo-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--dark); display: grid; place-items: center; }
.logo-mark svg { width: 16px; height: 16px; }
.nav-links { margin-left: auto; display: flex; gap: 4px; }
.nav-links button { border: 0; background: none; color: var(--ink-2); font-size: 14px; padding: 8px 12px; border-radius: 999px; }
.nav-links button.on { background: var(--ink); color: #fff; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 999px; padding: 13px 26px; font-weight: 600; font-size: 16px; text-decoration: none; transition: transform .15s, opacity .15s, background .15s; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-dark { background: var(--ink); color: #fff; }
.btn-blue { background: var(--accent); color: #fff; }
.btn-light { background: #fff; color: var(--ink); }
.btn-ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
.btn-line { background: var(--line-green); color: #fff; }
.btn-danger { background: transparent; color: var(--red); box-shadow: inset 0 0 0 1px #ffd0cc; }
.btn-block { display: flex; width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 14px; }
.link { border: 0; background: none; color: var(--accent); padding: 4px 0; font-weight: 500; }

/* ---------- cards / forms ---------- */
.card { background: var(--card); border-radius: var(--r-lg); padding: 22px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card-title { font-size: 19px; font-weight: 700; margin: 0 0 4px; letter-spacing: -.01em; }
.card-sub { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field > span em { color: var(--red); font-style: normal; margin-left: 2px; }
.field small { display: block; color: var(--muted); font-size: 12px; margin-top: 5px; }
.input, select.input, textarea.input { display: block; width: 100%; padding: 12px 14px; font: inherit; font-size: 16px; color: var(--ink); background: #fff; border: 1px solid var(--line-2); border-radius: var(--r-sm); -webkit-appearance: none; appearance: none; transition: border-color .15s, box-shadow .15s; }
select.input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2386868b' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(0,113,227,.15); }
.input.bad { border-color: var(--red); box-shadow: 0 0 0 4px rgba(255,59,48,.12); }
textarea.input { min-height: 84px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 2fr; gap: 0 12px; }
@media (max-width: 520px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-block; padding: 8px 15px; border-radius: 999px; background: #fff; border: 1px solid var(--line-2); font-size: 14px; color: var(--ink); transition: all .15s; user-select: none; }
.chip input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip input:focus-visible + span { box-shadow: 0 0 0 4px rgba(0,113,227,.25); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--ink); flex: none; }
.err { color: var(--red); font-size: 14px; min-height: 1.2em; margin: 10px 0 0; }
.note { background: #f5f5f7; border-radius: var(--r); padding: 14px 16px; font-size: 14px; color: var(--ink-2); }
.note b { color: var(--ink); }
.note ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- badges / status ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: color-mix(in srgb, var(--c) 14%, white); color: color-mix(in srgb, var(--c) 80%, black); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }

/* ---------- progress stepper ---------- */
.stepper { display: flex; justify-content: space-between; position: relative; margin: 8px 0 4px; }
.stepper::before { content: ""; position: absolute; left: 16px; right: 16px; top: 15px; height: 3px; background: var(--line); border-radius: 2px; }
.stepper .fill { position: absolute; left: 16px; top: 15px; height: 3px; background: var(--c); border-radius: 2px; transition: width .6s cubic-bezier(.2,.8,.2,1); }
.stepper .st { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.stepper .dot { width: 32px; height: 32px; border-radius: 50%; background: #fff; border: 3px solid var(--line); display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--muted); transition: all .3s; }
.stepper .st.done .dot { background: var(--c); border-color: var(--c); color: #fff; }
.stepper .st.cur .dot { background: #fff; border-color: var(--c); color: var(--c); box-shadow: 0 0 0 6px color-mix(in srgb, var(--c) 18%, transparent); }
.stepper .lbl { font-size: 11px; color: var(--muted); text-align: center; line-height: 1.3; }
.stepper .st.cur .lbl { color: var(--ink); font-weight: 700; }
.stepper .st.done .lbl { color: var(--ink-2); }
.mini-bar { height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.mini-bar i { display: block; height: 100%; background: var(--c); border-radius: 3px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 26px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 10px; height: 10px; border-radius: 50%; background: var(--line-2); }
.timeline li::after { content: ""; position: absolute; left: 8px; top: 20px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::after { display: none; }
.timeline li:first-child::before { background: var(--c, var(--ink)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c, #000) 18%, transparent); }
.timeline b { font-size: 15px; }
.timeline time { display: block; font-size: 12px; color: var(--muted); }

.kv { display: grid; grid-template-columns: 92px 1fr; gap: 10px 12px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; white-space: pre-line; }

/* ---------- login ---------- */
.login-card { max-width: 420px; margin: 0 auto; text-align: center; padding: 34px 26px 26px; }
.login-card .btn-block + .g-wrap { margin-top: 10px; }
.g-wrap { display: flex; justify-content: center; min-height: 44px; }
.g-wrap .btn { gap: 10px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 22px 0 14px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- 檢測報告 ---------- */
.rep-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 6px; }
.rep-item { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 16px; }
.rep-title { font-size: 17px; font-weight: 700; }
.rep-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.tag { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: #f2f2f4; color: var(--ink-2); }
.tag.ok { background: #e8f7ee; color: #1f7a45; }
.tag.bad { background: #fdecec; color: #c4302b; }
.rep-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-bottom: 14px; }
.rep-photos figure { margin: 0; }
.rep-photos img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 10px; background: #eceef1; display: block; cursor: zoom-in; }
.rep-photos img.broken { cursor: default; }
.rep-photos figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; }
.rep-checks { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
@media (max-width: 560px) { .rep-checks { grid-template-columns: 1fr; } }
.chk { display: flex; gap: 8px; align-items: flex-start; padding: 7px 0; border-top: 1px solid #f2f2f4; font-size: 14px; }
.chk .ico { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #fff; flex: none; margin-top: 1px; }
.chk.ok .ico { background: #1f9d55; } .chk.bad .ico { background: #e5484d; } .chk.na .ico { background: #c7c7cc; }
.chk .lbl { flex: 1; } .chk .lbl small { display: block; color: var(--muted); font-size: 12px; }
.chk .res { font-size: 12px; font-weight: 700; white-space: nowrap; }
.chk.ok .res { color: #1f9d55; } .chk.bad .res { color: #e5484d; } .chk.na .res { color: var(--muted); }
.rep-price { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 14px; border-top: 2px solid var(--ink); }
.rep-price td { padding: 7px 0; } .rep-price td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.rep-price .minus td { color: var(--ink-2); padding: 4px 0; } .rep-price .minus td:last-child { color: var(--red); }
.rep-price .sub td { font-weight: 700; border-top: 1px solid var(--line); }
.rep-total { display: flex; justify-content: space-between; align-items: center; background: var(--ink); color: #fff; border-radius: 14px; padding: 16px 18px; margin-top: 16px; }
.rep-total b { font-size: 26px; letter-spacing: -.02em; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 200; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 82vh; border-radius: 8px; }
.lightbox p { color: #fff; margin: 12px 0 0; font-size: 15px; }
@media print {
  body.printing * { visibility: hidden; }
  body.printing #report, body.printing #report * { visibility: visible; }
  body.printing #report { position: absolute; left: 0; top: 0; width: 100%; box-shadow: none; }
  body.printing .no-print { display: none; }
  .rep-item, .rep-photos figure { break-inside: avoid; }
}

/* ---------- 身分驗證（同意報價時） ---------- */
.id-box { border-top: 1px solid #f3dcb0; margin: 6px 0 4px; padding-top: 16px; }
.id-title { font-weight: 700; font-size: 15px; margin-bottom: 12px; }
.id-title small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.id-drop { display: grid; place-items: center; gap: 8px; min-height: 110px; border: 2px dashed var(--line-2); border-radius: 12px; background: #fff; cursor: pointer; padding: 10px; text-align: center; color: var(--ink-2); font-weight: 600; font-size: 15px; }
.id-drop:hover { border-color: var(--ink); }
.id-drop.has { border-style: solid; }
.id-drop.has .id-empty { order: 2; font-size: 13px; color: var(--accent); }
.id-drop img { width: 100%; max-width: 420px; border-radius: 8px; display: block; }

/* ---------- 確認視窗 ---------- */
.ask-wrap { position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 20px; animation: rise .2s ease both; }
.ask-box { background: #fff; border-radius: 18px; padding: 22px 20px 16px; width: 100%; max-width: 360px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.ask-box p { margin: 0 0 18px; font-size: 16px; line-height: 1.6; text-align: center; }
.ask-btns { display: flex; gap: 10px; }
.ask-btns .btn { flex: 1; padding: 12px; }

/* ---------- misc ---------- */
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: spin .8s linear infinite; margin: 60px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.rise { animation: rise .45s cubic-bezier(.2,.8,.2,1) both; }
#toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: rgba(29,29,31,.92); color: #fff; padding: 12px 20px; border-radius: 999px; font-size: 14px; opacity: 0; transition: all .25s; pointer-events: none; z-index: 100; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.footer { padding: 40px 0 60px; color: var(--muted); font-size: 13px; text-align: center; }
.footer a { color: var(--ink-2); }
