/* 版面:手機為單欄 App(上方標題列、下方四個大按鍵);管理後台為左側選單加寬版表格 */
:root {
  --bg: #EDF0F3; --surface: #FFFFFF; --tile: #E2E8ED; --ink: #14222C; --muted: #465763; --line: #CFD7DE;
  --brand: #1D3B4E; --brand-ink: #FFFFFF; --accent: #C8561A; --accent-ink: #FFFFFF; --accent-soft: #FBE9DD;
  --ok: #1B6E46; --ok-soft: #DDF1E6; --warn: #8A4B00; --warn-soft: #FCEBCF; --bad: #A8231C; --bad-soft: #FADFDC;
  --shadow: 0 1px 2px rgba(20, 34, 44, .08), 0 6px 18px rgba(20, 34, 44, .06);
  --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --r: 14px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0E161C; --surface: #18242D; --tile: #22313C; --ink: #E9EFF3; --muted: #A9B8C3; --line: #2E3D49;
  --brand: #16303F; --brand-ink: #F2F6F8; --accent: #F0894A; --accent-ink: #1A0E05; --accent-soft: #3A2415;
  --ok: #6FD3A0; --ok-soft: #173326; --warn: #F2BE6B; --warn-soft: #3A2C12; --bad: #F2948D; --bad-soft: #3D1B18;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #0E161C; --surface: #18242D; --tile: #22313C; --ink: #E9EFF3; --muted: #A9B8C3; --line: #2E3D49;
  --brand: #16303F; --brand-ink: #F2F6F8; --accent: #F0894A; --accent-ink: #1A0E05; --accent-soft: #3A2415;
  --ok: #6FD3A0; --ok-soft: #173326; --warn: #F2BE6B; --warn-soft: #3A2C12; --bad: #F2948D; --bad-soft: #3D1B18;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark }

* { box-sizing: border-box }
html, body { height: 100% }
body { margin: 0; background: var(--bg); color: var(--ink); font: 18px/1.55 var(--font); -webkit-text-size-adjust: 100% }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--brand) }
h1, h2, h3, p { margin: 0 }
h2 { font-size: 1.2rem; font-weight: 700; text-wrap: balance }
h3 { font-size: 1.05rem; font-weight: 700 }
button, input, select, textarea { font: inherit; color: inherit }
button { cursor: pointer }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px }
.muted { color: var(--muted) } .small { font-size: .9rem } .num { font-variant-numeric: tabular-nums }
.stack { display: flex; flex-direction: column; gap: 14px } .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap }
.grow { flex: 1; min-width: 0 }

/* 手機 App 外框 */
.phone { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; background: var(--bg) }
.bar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--brand); color: var(--brand-ink); display: flex; align-items: center; gap: 6px; min-height: 60px;
  padding-block: 6px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)) }
.bar h1 { font-size: 1.2rem; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.bar .logo { display: flex; align-items: center; gap: 8px }
.bar button { background: transparent; border: 1px solid rgba(255, 255, 255, .35); color: inherit; border-radius: 10px; min-height: 44px; padding: 0 12px; position: relative; white-space: nowrap }
.bar button.back { border: 0; padding: 0 10px 0 0; font-size: 1.05rem }
.page { flex: 1; padding-block: 16px 110px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 16px }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; justify-content: center; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px); padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px) }
.tabs .in { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; max-width: 560px }
.tabs button { background: none; border: 0; min-height: 68px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .95rem; font-weight: 500; color: var(--muted); position: relative }
.tabs button svg { width: 26px; height: 26px }
.tabs button[aria-current="page"] { color: var(--accent); font-weight: 700 }
.dot { position: absolute; top: 6px; right: 6px; min-width: 22px; height: 22px; border-radius: 11px; background: var(--bad); color: #fff; font-size: .78rem; font-weight: 700; display: grid; place-items: center; padding: 0 5px }
.tabs .dot { right: calc(50% - 30px) }

/* 按鍵 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 56px; padding: 0 20px; border-radius: var(--r); border: 1.5px solid var(--line); background: var(--surface); font-weight: 700; text-decoration: none; color: var(--ink) }
.btn.wide { width: 100% } .btn.sm { min-height: 46px; padding: 0 14px; font-size: .95rem; border-radius: 10px }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink) }
.btn.brand { background: var(--brand); border-color: var(--brand); color: var(--brand-ink) }
.btn.danger { color: var(--bad); border-color: var(--bad) }
.btn[disabled] { opacity: .5; cursor: not-allowed }
.link { background: none; border: 0; padding: 8px 0; color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: 3px }

/* 表單 */
label.f { display: flex; flex-direction: column; gap: 6px; font-weight: 700 }
label.f .hint { font-weight: 400; color: var(--muted); font-size: .9rem }
input[type=text], input[type=tel], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; min-height: 56px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface) }
textarea { min-height: 96px; resize: vertical }
.pair { display: grid; grid-template-columns: 1fr 132px; gap: 10px }
.check { display: flex; gap: 12px; align-items: flex-start; font-weight: 500 }
.check input { width: 28px; height: 28px; flex: none; margin-top: 2px; accent-color: var(--accent) }

/* 卡片與清單 */
.card { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px }
.banner { border-radius: 12px; padding: 12px 14px; background: var(--warn-soft); color: var(--warn); font-weight: 500 }
.banner.info { background: var(--tile); color: var(--ink) }
.search { display: grid; grid-template-columns: 1fr auto; gap: 10px }
.cats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px }
.cat { background: var(--surface); border: 0; border-radius: var(--r); box-shadow: var(--shadow); padding: 12px 6px; display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 104px; font-size: .95rem; font-weight: 500; line-height: 1.3 }
.cat svg { width: 40px; height: 40px; color: var(--brand) } .cat .n { color: var(--muted); font-size: .82rem }
.item { background: var(--surface); border: 0; border-radius: var(--r); box-shadow: var(--shadow); padding: 12px; display: grid; grid-template-columns: 92px 1fr; gap: 14px; text-align: left; width: 100%; align-items: center }
.thumb { width: 92px; height: 92px; border-radius: 10px; background: var(--tile); display: grid; place-items: center; overflow: hidden; color: var(--brand) }
.thumb img { width: 100%; height: 100%; object-fit: cover } .thumb svg { width: 52px; height: 52px }
.item .t { font-weight: 700; font-size: 1.08rem; line-height: 1.35 } .item .price { color: var(--accent); font-weight: 700 }
.hero { aspect-ratio: 4 / 3; max-width: 100%; border-radius: var(--r); background: var(--tile); display: grid; place-items: center; overflow: hidden; color: var(--brand) }
.hero img { width: 100%; height: 100%; object-fit: contain; background: var(--surface) } .hero svg { width: 120px; height: 120px }
.shots { display: flex; gap: 8px; overflow-x: auto } .shots button, .shots .ph { flex: none; width: 76px; height: 76px; border-radius: 10px; overflow: hidden; border: 2px solid var(--line); padding: 0; background: var(--tile); position: relative }
.shots img { width: 100%; height: 100%; object-fit: cover } .shots .x { position: absolute; top: 0; right: 0; width: 30px; height: 30px; border: 0; border-radius: 0 0 0 10px; background: var(--bad); color: #fff; font-weight: 700 }
.spec { display: grid; grid-template-columns: auto 1fr; gap: 10px 18px } .spec dt { color: var(--muted) } .spec dd { margin: 0; font-weight: 500; overflow-wrap: anywhere }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .85rem; font-weight: 700; background: var(--tile) }
.pill.ok { background: var(--ok-soft); color: var(--ok) } .pill.warn { background: var(--warn-soft); color: var(--warn) } .pill.bad { background: var(--bad-soft); color: var(--bad) }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--tile); border-radius: 12px; padding: 4px; gap: 4px }
.seg button { border: 0; background: none; min-height: 48px; border-radius: 9px; font-weight: 700; color: var(--muted) } .seg button[aria-pressed=true] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow) }
.phoneno { font-size: 1.35rem; font-weight: 700; user-select: all; font-variant-numeric: tabular-nums }
.cta { position: fixed; bottom: 0; left: 0; right: 0; z-index: 21; background: var(--surface); border-top: 1px solid var(--line); display: flex; justify-content: center;
  padding-block: 10px calc(10px + env(safe-area-inset-bottom, 0px)); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)) }
.cta > * { max-width: 528px }
.note { border-left: 5px solid var(--line); } .note.unread { border-left-color: var(--accent) }
.bubble { max-width: 85%; padding: 10px 14px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); overflow-wrap: anywhere } .bubble.me { align-self: flex-end; background: var(--accent-soft) }
.empty { text-align: center; color: var(--muted); padding: 28px 8px }
.terms { max-height: 260px; overflow-y: auto; border: 1.5px solid var(--line); border-radius: 12px; padding: 14px; background: var(--surface) } .terms ol { margin: 8px 0 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 8px }
.brandmark { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 0 4px; text-align: center } .brandmark svg { width: 76px; height: 76px; color: var(--brand) } .brandmark .name { font-size: 1.9rem; font-weight: 700; letter-spacing: .12em }

/* 彈出視窗與提示 */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(8, 14, 18, .6); display: grid; place-items: end center; padding: 0 }
.sheet { background: var(--surface); width: 100%; max-width: 560px; border-radius: 20px 20px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 14px; max-height: 92%; overflow-y: auto }
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 60; background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 700; max-width: calc(100% - 32px); text-align: center }
.toast.err { background: var(--bad); color: #fff }

/* 管理後台 */
.admin { min-height: 100%; display: grid; grid-template-columns: 220px 1fr }
.side { background: var(--brand); color: var(--brand-ink); padding: 18px 12px; display: flex; flex-direction: column; gap: 6px }
.side .logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.15rem; padding: 4px 8px 14px } .side svg { width: 30px; height: 30px }
.side button { background: none; border: 0; color: inherit; text-align: left; min-height: 48px; padding: 0 12px; border-radius: 10px; font-weight: 500; position: relative; white-space: nowrap }
.side button[aria-current="page"] { background: rgba(255, 255, 255, .16); font-weight: 700 } .side .dot { top: 13px; right: 10px }
.main { padding-block: 22px 40px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 18px; min-width: 0 }
.main > * { max-width: 1180px } .main h2 { font-size: 1.45rem }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px } .kpi { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 16px } .kpi b { display: block; font-size: 1.9rem; font-variant-numeric: tabular-nums; line-height: 1.2 } .kpi.alert b { color: var(--accent) }
.tw { overflow-x: auto; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow) }
table { border-collapse: collapse; width: 100%; font-size: .95rem } th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle } th { color: var(--muted); font-weight: 700; white-space: nowrap; background: var(--tile) } td.act { white-space: nowrap } tr:last-child td { border-bottom: 0 }
.admin input[type=search], .admin select, .admin input[type=number], .admin input[type=text] { min-height: 46px; padding: 8px 12px; font-size: .95rem } .admin .tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center } .admin .tools input { max-width: 320px }
.two { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start } .tlist button { display: block; width: 100%; text-align: left; background: var(--surface); border: 0; border-bottom: 1px solid var(--line); padding: 12px 14px; position: relative } .tlist button[aria-pressed=true] { background: var(--accent-soft) }
@media (max-width: 820px) {
  .admin { grid-template-columns: 1fr; grid-template-rows: auto 1fr } .side { flex-direction: row; overflow-x: auto; padding: 8px; align-items: center; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20 } .side .logo { padding: 0 8px } .side .logo span { display: none } .side .sp { display: none }
  .two { grid-template-columns: 1fr }
}
@media (min-width: 821px) { .admin .overlay { place-items: center } .admin .sheet { border-radius: 18px; max-width: 520px } }
@media (prefers-reduced-motion: no-preference) { .sheet { animation: up .18s ease-out } @keyframes up { from { transform: translateY(24px) } } }
