/* 點好餐 — 共用樣式（品牌色、按鈕、表單、對話框、提示） */
:root {
  --brand: #D9480F;
  --brand-dark: #B83A0A;
  --brand-soft: #FDEEE6;
  --ink: #1F1B18;
  --ink-2: #4A433D;
  --muted: #857B72;
  --bg: #F7F4F0;
  --card: #FFFFFF;
  --line: #ECE5DD;
  --line-2: #DDD3C8;
  --ok: #2F7D4A;
  --ok-soft: #E7F3EA;
  --warn: #B26A00;
  --warn-soft: #FFF4DE;
  --danger: #C0392B;
  --danger-soft: #FCEBE9;
  --info: #2D5F8B;
  --info-soft: #E8F0F8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(31,27,24,.06), 0 4px 16px rgba(31,27,24,.06);
  --font: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Noto Sans Thai", "Leelawadee UI", "Hiragino Sans", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
body.modal-open { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--brand); }
img { max-width: 100%; }
.hidden { display: none !important; }
.ic { flex-shrink: 0; vertical-align: middle; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--card);
  font-size: 15px; font-weight: 600; min-height: 44px; text-decoration: none; color: var(--ink); white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-ghost { color: var(--danger); border-color: #EBC2BC; }
.btn.ghost { background: transparent; }
.btn.soft { background: var(--brand-soft); border-color: transparent; color: var(--brand-dark); }
.btn.block { display: flex; width: 100%; }
.btn.sm { min-height: 34px; padding: 5px 11px; font-size: 14px; border-radius: 8px; }
.btn.xs { min-height: 28px; padding: 3px 9px; font-size: 13px; border-radius: 7px; }
.btn.lg { min-height: 52px; font-size: 17px; }
.btn[disabled], .btn.disabled { opacity: .45; pointer-events: none; }
.btn { max-width: 100%; }
.btn.block, .btn.lg { white-space: normal; text-align: center; line-height: 1.3; overflow-wrap: anywhere; } /* 長店名的大按鈕自動換行，不超出格子 */
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; color: var(--ink-2); }
.icon-btn:hover { background: rgba(0,0,0,.05); }

.badge { display: inline-flex; align-items: center; gap: 3px; padding: 1px 8px; border-radius: 99px; font-size: 12.5px; font-weight: 600; background: #EEE9E3; color: var(--ink-2); white-space: nowrap; line-height: 1.6; }
.badge.brand { background: var(--brand-soft); color: var(--brand-dark); }
.badge.ok, .badge.paid, .badge.ready, .badge.completed-ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn, .badge.unpaid, .badge.accepted, .badge.preparing { background: var(--warn-soft); color: var(--warn); }
.badge.danger, .badge.pending, .badge.refund { background: var(--danger-soft); color: var(--danger); }
.badge.info, .badge.web { background: var(--info-soft); color: var(--info); }
.badge.pos { background: #F1ECF7; color: #5B3E86; }
.badge.completed { background: #EEE9E3; color: var(--muted); }
.badge.cancelled { background: #EEE9E3; color: var(--muted); text-decoration: line-through; }

/* 表單 */
.field { display: block; margin-bottom: 14px; }
.field > span, .form label { display: block; font-size: 14px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.req { color: var(--danger); font-style: normal; }
input[type=text], input[type=tel], input[type=number], input[type=password], input[type=search], input[type=date], input[type=time], input[type=datetime-local], input[type=url], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 10px; background: #fff; min-height: 44px; font-size: 16px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(217,72,15,.12); }
textarea { resize: vertical; min-height: 80px; }
.hint { display: block; font-size: 13px; color: var(--muted); margin-top: 4px; }
.err-text { color: var(--danger); font-size: 13.5px; margin-top: 4px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 15px; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch i { width: 44px; height: 26px; border-radius: 99px; background: #D7CFC6; position: relative; transition: .2s; flex-shrink: 0; }
.switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + i { background: var(--ok); }
.switch input:checked + i::after { left: 21px; }
.switch input:focus-visible + i { box-shadow: 0 0 0 3px rgba(217,72,15,.25); }

/* 提示 */
.toast {
  position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top)); transform: translate(-50%, -16px); opacity: 0;
  background: rgba(31,27,24,.94); color: #fff; padding: 11px 18px; border-radius: 12px; z-index: 9999;
  transition: .2s; pointer-events: none; max-width: min(92vw, 520px); text-align: center; font-size: 15px; font-weight: 500;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }

/* 對話框／底部抽屜 */
.modal-wrap { position: fixed; inset: 0; background: rgba(31,27,24,.45); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 16px; opacity: 0; transition: opacity .18s; }
.modal-wrap.in { opacity: 1; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 460px; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.modal-wrap.wide .modal { max-width: 760px; }
.modal-wrap.xwide .modal { max-width: 1000px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 12px 20px; border-bottom: 1px solid var(--line); }
.modal-head b { flex: 1; font-size: 17px; }
.modal-head .x { width: 36px; height: 36px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-2); }
.modal-head .x:hover { background: #F2EEE9; }
.modal-body { padding: 18px 20px; overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; }
.modal-foot { display: flex; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); justify-content: flex-end; background: #fff; }
.modal-foot .btn { min-width: 96px; }
.confirm-msg { margin: 4px 0; font-size: 16px; white-space: pre-line; }
@media (max-width: 640px) {
  .modal-wrap.sheet { align-items: flex-end; padding: 0; }
  .modal-wrap.sheet .modal { max-width: none; border-radius: 18px 18px 0 0; max-height: 92vh; max-height: 92dvh; transform: translateY(30px); transition: transform .22s; }
  .modal-wrap.sheet.in .modal { transform: none; }
  .modal-foot .btn { flex: 1; }
}

.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty .ic { color: #C9BFB4; margin-bottom: 8px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: 10px; background: var(--warn-soft); color: #6B4300; font-size: 14px; }
.notice.info { background: var(--info-soft); color: #1F4366; }
.notice.danger { background: var(--danger-soft); color: #7D241A; }
.notice.ok { background: var(--ok-soft); color: #1E5131; }
.notice .ic { margin-top: 2px; }
