* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif; background: #f8f9fa; color: #212529; font-size: 14px; }
button, input, select, textarea { font: inherit; }
.hd { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; background: #fff; border-bottom: 1px solid #e9ecef; padding: 10px 16px; }
.brand { font-weight: 700; color: #d6336c; font-size: 16px; }
.sp { flex: 1; }
.nav { position: relative; display: flex; flex-wrap: wrap; gap: 2px; background: #fff; border-bottom: 1px solid #e9ecef; padding: 0 12px; }
.nav a { padding: 10px 12px; cursor: pointer; color: #495057; border-bottom: 3px solid transparent; white-space: nowrap; }
.nav a.on { color: #d6336c; border-color: #d6336c; font-weight: 600; }
main { padding: 16px; max-width: 1200px; margin: 0 auto; }
h2 { font-size: 18px; margin: 4px 0 12px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
.muted { color: #868e96; }
.card { background: #fff; border-radius: 10px; padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 2px #0000000d; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid #f1f3f5; vertical-align: top; }
th { background: #f8f9fa; font-weight: 600; color: #495057; white-space: nowrap; }
.btn { border: 0; border-radius: 6px; padding: 7px 14px; background: #d6336c; color: #fff; cursor: pointer; }
.btn.ghost { background: #fff; color: #d6336c; border: 1px solid #d6336c; }
.btn.gray { background: #e9ecef; color: #495057; }
.btn.small { padding: 3px 9px; font-size: 13px; }
.btn.danger { background: #fa5252; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
input, select, textarea { border: 1px solid #ced4da; border-radius: 6px; padding: 6px 8px; background: #fff; }
input[type=number] { width: 90px; }
label { display: inline-flex; flex-direction: column; gap: 3px; color: #495057; font-size: 13px; }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.form label input, .form label select, .form label textarea { width: 100%; }
.st { padding: 1px 7px; border-radius: 99px; font-size: 12px; white-space: nowrap; }
.st.booked { background: #e7f5ff; color: #1c7ed6; }
.st.completed { background: #ebfbee; color: #2f9e44; }
.st.no_show { background: #fff4e6; color: #e8590c; }
.st.cancelled { background: #f1f3f5; color: #868e96; }
.toast { position: fixed; right: 16px; bottom: 16px; background: #212529; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 99; }
dialog { border: 0; border-radius: 10px; padding: 18px; min-width: 340px; max-width: 95vw; box-shadow: 0 10px 40px #0003; }
dialog .form { grid-template-columns: 1fr 1fr; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.grid-cal { overflow-x: auto; }
.grid-cal table td { min-width: 120px; height: 26px; padding: 2px 4px; font-size: 12px; border: 1px solid #f1f3f5; }
.grid-cal td.time { min-width: 50px; color: #868e96; }
.grid-cal .bk { background: #ffdeeb; border-left: 3px solid #d6336c; border-radius: 3px; padding: 2px 4px; cursor: pointer; }
.grid-cal .off { background: #f1f3f5; }
.kpi { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi div { background: #fff; border-radius: 10px; padding: 12px; box-shadow: 0 1px 2px #0000000d; }
.kpi b { display: block; font-size: 22px; margin-top: 4px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.barc { height: 8px; background: #d6336c; border-radius: 4px; }
code { background: #f1f3f5; padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
.kv { display: inline-block; margin-right: 14px; }
.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login .box { background: #fff; padding: 28px; border-radius: 12px; width: 320px; box-shadow: 0 4px 20px #0001; display: flex; flex-direction: column; gap: 12px; }
.login h1 { font-size: 18px; margin: 0 0 6px; color: #d6336c; }
.login input { width: 100%; padding: 9px; }
.err { color: #fa5252; min-height: 1em; margin: 0; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: #fa5252; color: #fff; font-size: 11px; text-align: center; line-height: 18px; }
.unread td { font-weight: 600; }
.inbox { display: grid; grid-template-columns: 280px 1fr; gap: 12px; }
.inbox .list .it { padding: 10px; border-bottom: 1px solid #f1f3f5; cursor: pointer; }
.inbox .list .it.on { background: #fff0f6; }
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; padding: 4px; }
.msg { max-width: 75%; padding: 8px 12px; border-radius: 12px; background: #f1f3f5; word-break: break-word; }
.msg .tx, .msg .tr { white-space: pre-wrap; }
.msg.out { align-self: flex-end; background: #ffdeeb; }
.msg .tr { margin-top: 6px; padding-top: 6px; border-top: 1px dashed #ced4da; color: #495057; }
.msg .meta { font-size: 11px; color: #868e96; margin-top: 4px; }
.rm-img { max-width: 100%; border: 1px solid #e9ecef; border-radius: 8px; }
@media (max-width: 760px) { .inbox { grid-template-columns: 1fr; } }
.grp td { background: #fff0f6; color: #d6336c; font-weight: 600; }
.note { color: #d6336c; font-size: 12px; }
.svc-grp { margin-bottom: 6px; }
.svc-grp b { display: block; font-size: 12px; color: #d6336c; margin-bottom: 2px; }
/* 多語系：語言選單、表格橫向捲動、行內標籤 */
.lang-sel { padding: 3px 6px; font-size: 13px; }
.login-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.login-top h1 { margin: 0; }
.tw { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 4px; }
.tw table { min-width: 100%; }
.nowrap, .acts { white-space: nowrap; }
label.inl { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 4px 6px; margin: 4px 12px 4px 0; }
.w300 { width: 300px; max-width: 100%; }
.w200 { width: 200px; max-width: 100%; }
#who { overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .hd { padding: 8px 12px; }
  .brand { font-size: 15px; }
  #who { order: 10; flex-basis: 100%; font-size: 12px; }
  .nav { flex-wrap: nowrap; overflow-x: auto; padding: 0 4px; scrollbar-width: none; }
  .nav a { padding: 10px 9px; }
  main { padding: 12px; }
  .tw.wide table { min-width: 720px; }
  dialog { min-width: 0; width: 95vw; padding: 14px; }
  dialog .form { grid-template-columns: 1fr; }
  .row .sp { display: none; }
  .toast { left: 12px; right: 12px; }
}
/* 手機：預約列表改卡片式（每格顯示 data-label 欄名） */
@media (max-width: 760px) {
  .tw.cards table, .tw.cards tbody, .tw.cards tr, .tw.cards td { display: block; width: 100%; }
  .tw.cards thead { display: none; }
  .tw.cards tr { position: relative; background: #fff; border-radius: 10px; box-shadow: 0 1px 2px #0000000d; margin-bottom: 10px; padding: 8px 10px; }
  .tw.cards td { position: relative; border: 0; padding: 3px 0 3px 34%; white-space: normal; min-height: 22px; }
  .tw.cards td[data-label]::before { content: attr(data-label); position: absolute; left: 0; top: 4px; width: 32%; color: #868e96; font-size: 12px; overflow-wrap: anywhere; }
  .tw.cards td[colspan] { padding-left: 0; }
  .tw.cards td.act { padding: 6px 0 2px; text-align: right; border-top: 1px solid #f1f3f5; margin-top: 4px; }
  .tw.cards td.act:empty { display: none; }
  .tw.cards table { background: transparent; }
}
label.inl.chk { flex-wrap: nowrap; align-items: flex-start; }
label.inl.chk input { margin-top: 3px; flex: none; }
a.btn { text-decoration: none; display: inline-block; }
.daynav { display: inline-flex; gap: 8px; align-items: center; }
.daynav .short { display: none; }
@media (max-width: 760px) {
  .daynav { display: flex; width: 100%; }
  .daynav input { flex: 1; min-width: 0; }
  .daynav .full { display: none; }
  .daynav .short { display: inline; font-size: 16px; line-height: 1; }
}
.form label input[type=checkbox] { width: auto; flex: none; }
.form label:has(> input[type=checkbox]) { gap: 6px; align-items: flex-start !important; }
.form label:has(> input[type=checkbox]) input { margin-top: 3px; }
/* 訊息回覆送出中 */
.send-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; padding: 8px 12px; border-radius: 8px; border: 1px dashed #d6336c; background: #fff0f6; color: #495057; font-size: 13px; }
.send-hint b { color: #d6336c; }
.send-hint.err { border: 1px solid #ffc9c9; background: #fff5f5; }
.send-hint.err b { color: #fa5252; }
.spin-s { width: 14px; height: 14px; border: 2px solid #f1d3dd; border-top-color: #d6336c; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn:disabled, textarea:disabled { opacity: 0.55; cursor: default; }
/* 常用回覆 */
.faq-stats { display: flex; flex-wrap: wrap; gap: 4px 0; }
.faq-runs { margin-top: 10px; }
.faq-runs summary { cursor: pointer; color: #495057; margin-bottom: 6px; }
.faq-list { display: grid; gap: 0; }
.faq-card { border-left: 4px solid #e9ecef; }
.faq-card.on { border-left-color: #2f9e44; }
.faq-top { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.faq-q { min-width: 0; overflow-wrap: anywhere; }
.faq-q b { font-size: 15px; }
.faq-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { display: inline-block; background: #f1f3f5; color: #495057; border-radius: 99px; padding: 1px 9px; font-size: 12px; overflow-wrap: anywhere; }
.chip.strong { background: #fff0f6; color: #d6336c; font-weight: 600; }
.faq-ans { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.faq-ans p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.faq-ex { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.switch { flex-direction: row !important; align-items: center; gap: 8px; flex: none; cursor: pointer; white-space: nowrap; font-weight: 600; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .knob { position: relative; width: 40px; height: 22px; border-radius: 99px; background: #ced4da; transition: background .15s; flex: none; }
.switch .knob::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px #0003; }
.switch input:checked + .knob { background: #2f9e44; }
.switch input:checked + .knob::after { transform: translateX(18px); }
.switch input:focus-visible + .knob { outline: 2px solid #d6336c; outline-offset: 2px; }
@media (max-width: 760px) {
  .faq-ans { grid-template-columns: 1fr; }
  .faq-top { flex-wrap: wrap; }
}
/* 日期／時間選擇器（vi／en；zh-TW 用原生） */
.dp-btn { display: inline-flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 9.5em; min-height: 34px; padding: 6px 8px; border: 1px solid #ced4da; border-radius: 6px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23868e96' stroke-width='1.6'%3E%3Crect x='2' y='3' width='12' height='11' rx='2'/%3E%3Cpath d='M2 6.5h12M5.5 1.5v3M10.5 1.5v3'/%3E%3C/svg%3E") no-repeat right 8px center;
  padding-right: 30px; color: #212529; text-align: left; cursor: pointer; font-variant-numeric: tabular-nums; }
.dp-btn.time { min-width: 6.5em; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23868e96' stroke-width='1.6'%3E%3Ccircle cx='8' cy='8' r='6'/%3E%3Cpath d='M8 4.5V8l2.5 1.5'/%3E%3C/svg%3E"); }
.dp-btn.empty { color: #868e96; }
.dp-btn:focus-visible { outline: 2px solid #d6336c; outline-offset: 1px; }
.form label .dp-btn { width: 100%; }
.dp-backdrop { position: fixed; inset: 0; z-index: 1000; background: transparent; }
.dp-panel { position: fixed; z-index: 1001; width: 296px; max-width: calc(100vw - 16px); background: #fff; border-radius: 12px; box-shadow: 0 10px 32px #0003; padding: 10px; color: #212529; font-size: 14px; }
.dp-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 6px; }
.dp-title { flex: 1; text-align: center; font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.dp-nav { width: 40px; height: 40px; border: 0; border-radius: 8px; background: #f1f3f5; font-size: 20px; line-height: 1; cursor: pointer; color: #495057; }
.dp-wd, .dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.dp-wd span { font-size: 12px; color: #868e96; padding: 4px 0; white-space: nowrap; }
.dp-day { height: 38px; border: 0; border-radius: 8px; background: none; cursor: pointer; font-variant-numeric: tabular-nums; color: #212529; }
.dp-day:hover { background: #fff0f6; }
.dp-day.today { box-shadow: inset 0 0 0 1px #d6336c; color: #d6336c; font-weight: 600; }
.dp-day.sel { background: #d6336c; color: #fff; font-weight: 600; }
.dp-day:focus-visible, .dp-nav:focus-visible, .dp-col button:focus-visible { outline: 2px solid #1c7ed6; outline-offset: 1px; }
.dp-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; padding-top: 8px; border-top: 1px solid #f1f3f5; }
.dp-time { width: 220px; }
.dp-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dp-colh { font-size: 12px; color: #868e96; text-align: center; margin-bottom: 4px; }
.dp-col { height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; padding: 2px; border: 1px solid #f1f3f5; border-radius: 8px; overscroll-behavior: contain; }
.dp-col button { flex: none; height: 36px; border: 0; border-radius: 6px; background: none; cursor: pointer; font-variant-numeric: tabular-nums; }
.dp-col button:hover { background: #fff0f6; }
.dp-col button.sel { background: #d6336c; color: #fff; font-weight: 600; }
@media (max-width: 760px) {
  .dp-btn { min-height: 44px; }
  .dp-backdrop { background: #0005; }
  .dp-panel.sheet { left: 0; right: 0; bottom: 0; top: auto; width: auto; max-width: none; border-radius: 16px 16px 0 0; padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); }
  .dp-panel.sheet .dp-nav { width: 48px; height: 48px; }
  .dp-panel.sheet .dp-title { font-size: 17px; }
  .dp-panel.sheet .dp-day { height: 46px; font-size: 16px; }
  .dp-panel.sheet .dp-col { height: 264px; }
  .dp-panel.sheet .dp-col button { height: 44px; font-size: 16px; }
  .dp-panel.sheet .dp-foot .btn { min-height: 44px; flex: 1; font-size: 15px; }
}
/* 現場客 */
.btns { display: inline-flex; flex-wrap: wrap; gap: 8px; }
.src-walkin { display: inline-block; padding: 1px 7px; border-radius: 99px; background: #fff4e6; color: #e8590c; font-size: 12px; white-space: nowrap; }
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.bar-top .bl { min-width: 0; overflow-wrap: anywhere; }
.bar-top .bv { flex: none; white-space: nowrap; color: #495057; font-variant-numeric: tabular-nums; }
.bar-track { height: 8px; background: #f8f0f3; border-radius: 4px; overflow: hidden; }
.wi-note { margin: -6px 0 10px; font-size: 12px; }
dialog .form.wi-form, .form.wi-form { grid-template-columns: 1fr 1fr; }
.wi-form .full, .wi-full { grid-column: 1 / -1; }
.wi-full { display: flex; width: 100%; margin-top: 10px; }
.wi-full textarea { width: 100%; }
.wi-h { margin: 14px 0 6px; }
.wi-svcs { max-height: 38vh; overflow-y: auto; border: 1px solid #f1f3f5; border-radius: 8px; padding: 8px; margin-bottom: 10px; overscroll-behavior: contain; }
.wi-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.wi-chip { flex-direction: row !important; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid #dee2e6; border-radius: 99px; background: #fff; cursor: pointer; color: #212529; font-size: 13px; }
.wi-chip:has(input:checked) { border-color: #d6336c; background: #fff0f6; color: #d6336c; font-weight: 600; }
.wi-amount input { font-size: 18px; font-weight: 700; }
.wi-cust { margin-top: 10px; }
.wi-cust summary { cursor: pointer; color: #495057; padding: 6px 0; }
.wi-list { display: flex; flex-direction: column; }
.wi-row { display: flex; gap: 12px; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #f1f3f5; }
.wi-main { min-width: 0; overflow-wrap: anywhere; }
.wi-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
#dlg:has(.wi-form) { width: min(640px, 95vw); }
@media (max-width: 760px) {
  dialog .form.wi-form { grid-template-columns: 1fr 1fr; }
  .wi-chip { min-height: 44px; font-size: 14px; }
  .wi-form input, .wi-form select, .wi-full textarea { min-height: 44px; font-size: 16px; }
  .wi-svcs { max-height: 34vh; }
  .wi-row { flex-direction: column; gap: 6px; }
  .wi-side { flex-direction: row; justify-content: space-between; align-items: center; }
  .btns { width: 100%; }
  .btns .btn { flex: 1; min-height: 40px; }
}
/* 現場客表單：儲存／取消固定在對話框底部（手機不用捲到最下面） */
#dlg:has(.wi-form) .actions { position: sticky; bottom: -18px; margin: 14px -18px -18px; padding: 10px 18px calc(10px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid #f1f3f5; z-index: 2; }
@media (max-width: 760px) {
  #dlg:has(.wi-form) .actions { bottom: -14px; margin: 14px -14px -14px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  #dlg:has(.wi-form) .actions .btn { flex: 1; min-height: 44px; font-size: 15px; }
}
