/* 1798 結帳系統 — 深色主題（延續舊版黑底黃字風格） */
:root {
  --bg: #0b0b0c;
  --panel: #161618;
  --panel2: #1f1f22;
  --line: #2e2e33;
  --text: #f2f2f2;
  --muted: #9a9aa2;
  --accent: #ffd54a;
  --accent-ink: #1a1400;
  --ok: #3ecf8e;
  --ok-bg: #10291f;
  --warn: #ffb340;
  --warn-bg: #33250b;
  --bad: #ff6b6b;
  --bad-bg: #3a1414;
  --info: #8fb4ff;
  --info-bg: #142038;
  --radius: 8px;
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", system-ui, sans-serif; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 10px; font-weight: 700; }
h2 { font-size: 1.05rem; color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.err { color: var(--bad); min-height: 1.2em; }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.warn-text { color: var(--warn); font-size: .85rem; margin-top: 4px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* 表單元件 */
input, select, textarea, button { font: inherit; }
input, select, textarea {
  background: #0f0f11; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); vertical-align: middle; }
input[type=date] { color-scheme: dark; }
.btn {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 7px 14px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: wait; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.btn.big { width: 100%; padding: 12px; font-size: 1.05rem; }
.btn.small { padding: 4px 10px; font-size: .85rem; }
.btn.tiny { padding: 2px 8px; font-size: .8rem; margin: 1px 2px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }

/* 登入 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; display: flex; flex-direction: column; gap: 12px; }
.login-box label { display: flex; flex-direction: column; gap: 4px; color: var(--accent); }
.login-box h1 { text-align: center; font-size: 1.3rem; }
.login-logo { width: 220px; max-width: 100%; margin: 6px auto 4px; }

/* 外框 */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 8px 16px; background: #000; border-bottom: 1px solid var(--line); }
.topbar .logo { height: 30px; width: auto; }
.tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.tab { background: none; border: 0; color: var(--muted); padding: 8px 12px; border-radius: 6px; cursor: pointer; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--panel2); color: var(--accent); font-weight: 700; }
.userbox { display: flex; align-items: center; gap: 8px; }
.who { color: var(--muted); font-size: .9rem; }
.sync-dot { width: 10px; height: 10px; border-radius: 50%; background: #555; display: inline-block; }
.sync-dot.good { background: var(--ok); }
.sync-dot.bad { background: var(--bad); }
.main { padding: 14px 16px 40px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.panel-head, .toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.panel-head h2, .toolbar h2 { margin: 0; margin-right: auto; }
.narrow { max-width: 640px; }

/* 結帳頁 */
.checkout-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.date-label { font-weight: 700; color: var(--accent); }
.checkout { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 14px; align-items: start; }
.col-left { }
.form .row { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; gap: 8px; margin-bottom: 8px; }
.form .lbl { color: var(--accent); font-size: .92rem; }
.form .wide, .form .row input[type=text], .form .row input[type=email], .form .row input[type=password], .form .row input[type=number]:not(.num) { width: 100%; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper .num { width: 80px; text-align: center; font-size: 1.05rem; }
.step { width: 36px; height: 36px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font-size: 1.2rem; cursor: pointer; }
.step:hover { border-color: var(--accent); }
.price-hint { color: var(--muted); font-size: .85rem; margin: -4px 0 8px 104px; }
.amount { background: #000; border: 1px solid var(--line); border-radius: 6px; padding: 10px; margin: 10px 0; color: var(--accent); }
.amount b { font-size: 1.15rem; }
.amount.bad { border-color: var(--bad); color: var(--bad); }
.link-box { background: var(--info-bg); border: 1px solid var(--info); border-radius: 6px; padding: 8px 10px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--info); }
.cart { list-style: none; padding: 0; margin: 6px 0; border: 1px solid var(--line); border-radius: 6px; max-height: 180px; overflow: auto; }
.cart li { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--line); gap: 6px; font-size: .9rem; }
.cart li:last-child { border-bottom: 0; }

/* 表格 */
.table-wrap, .grid-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: #222226; color: #eee; position: sticky; top: 0; font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.note { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
td.actions { white-space: nowrap; }
tr.voided td { color: #666; text-decoration: line-through; }
tr.voided td:last-child { text-decoration: none; }
tr.review td { background: var(--warn-bg); }
tr.new-row td { background: #121a12; }
tfoot td { font-weight: 700; color: var(--accent); border-top: 2px solid var(--line); }
.records.editable input { padding: 4px 6px; }
.records.editable input.xs { width: 60px; }
.records.editable input.sm { width: 80px; }
.records.editable input.md { width: 150px; }
.records.editable input.lg { width: 260px; }

/* 場次對照表 */
.grid td.slot { font-weight: 700; font-size: 1rem; font-variant-numeric: tabular-nums; }
.grid td.theme { font-weight: 600; white-space: nowrap; }
.grid td.names { min-width: 120px; }
.g-row.empty td { color: #666; }
.g-row.booked td { background: var(--info-bg); }
.g-row.done td { background: var(--ok-bg); }
.g-row.late td { background: var(--bad-bg); }
.g-row.noshow td { background: #241a24; color: #bbb; }
.g-row.soon td:first-child { box-shadow: inset 4px 0 0 var(--accent); }
td.pos { color: var(--warn); }
td.neg { color: var(--bad); }
.strike { text-decoration: line-through; color: #777; }
.status { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: .8rem; background: #333; }
.st-booked { background: var(--info-bg); color: var(--info); border: 1px solid var(--info); }
.st-arrived { background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok); }
.st-noshow { background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad); }
.st-cancel { background: #2a2a2a; color: #999; border: 1px solid #555; }
.badge { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 8px; font-size: .75rem; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; font-size: .8rem; color: var(--muted); }
.lg::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.lg.done::before { background: var(--ok-bg); border: 1px solid var(--ok); }
.lg.booked::before { background: var(--info-bg); border: 1px solid var(--info); }
.lg.late::before { background: var(--bad-bg); border: 1px solid var(--bad); }
.lg.noshow::before { background: #241a24; border: 1px solid #885; }
.lg.soon::before { background: var(--accent); }

/* 合計 */
.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-bottom: 10px; }
.tot { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.tot span { color: var(--muted); font-size: .85rem; }
.tot b { font-size: 1.3rem; color: var(--accent); font-variant-numeric: tabular-nums; }
.tot.grand { border-color: var(--accent); }
.summary { display: flex; flex-direction: column; gap: 4px; color: #aaaaff; font-size: .9rem; }

/* 對話框與通知 */
.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .7); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; width: 100%; max-width: 480px; max-height: 92vh; overflow: auto; }
.modal-form label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; color: var(--accent); font-size: .92rem; }
.modal-form label.check { flex-direction: row; align-items: center; color: var(--text); }
.modal-form small { color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.raw pre, .log { white-space: pre-wrap; background: #000; border: 1px solid var(--line); border-radius: 6px; padding: 10px; max-height: 260px; overflow: auto; font-size: .8rem; color: #ccc; }
.raw summary { cursor: pointer; color: var(--info); margin: 6px 0; }
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ok-bg); border: 1px solid var(--ok); color: var(--text); padding: 10px 14px; border-radius: 8px; max-width: 420px; cursor: pointer; box-shadow: 0 4px 14px rgba(0, 0, 0, .5); }
.toast.err { background: var(--bad-bg); border-color: var(--bad); }
#big-toasts { position: fixed; left: 12px; top: 12px; z-index: 300; display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 24px); overflow-y: auto; }
.big-toast { width: 420px; max-width: calc(100vw - 24px); background: #000; border: 3px solid var(--accent); border-radius: 12px; padding: 14px 18px; cursor: pointer; box-shadow: 0 8px 30px rgba(0, 0, 0, .7); }
.bt-title { color: var(--accent); font-size: 1.4rem; font-weight: 800; margin-bottom: 6px; }
.bt-body { white-space: pre-line; font-size: 1.05rem; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.role-help { margin: 0 0 10px; padding-left: 18px; }

/* 安裝頁 */
.setup { padding: 20px; }
.setup-box { max-width: 560px; margin: 30px auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; }
.form-grid { display: flex; flex-direction: column; gap: 10px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; color: var(--accent); }
.form-grid h2 { margin-top: 10px; }
textarea.code { width: 100%; font-family: monospace; font-size: .8rem; }

/* 平板 / 手機 */
@media (max-width: 1100px) {
  .checkout { grid-template-columns: 1fr; }
  .col-left { position: static; }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; }
  .who { display: none; }
  .main { padding: 10px; }
}
@media print {
  .topbar, .col-left, .actions, .btn { display: none !important; }
  body { background: #fff; color: #000; }
}

/* 對照表：左預約、右實際輸入 */
.grid thead tr.group-head th { text-align: center; font-size: .85rem; }
.grid th.grp-res { background: #1b2740; color: var(--info); }
.grid th.grp-act { background: #1a3326; color: var(--ok); }
.grid .divider { border-left: 3px solid var(--accent); }
.grid td.big-num { font-size: 1.05rem; font-weight: 700; }
.grid td.diff { font-weight: 700; white-space: nowrap; }
.grid td.diff.match { color: var(--ok); }
.custom-row { margin: -2px 0 8px 104px; font-size: .82rem; }
.custom-box { display: inline-flex; gap: 6px; align-items: center; }
.custom-time { width: 120px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: .82rem; }
.link-btn:hover { color: var(--accent); }

/* 左預約、右主題明細並排 */
.side-by-side { display: grid; grid-template-columns: minmax(230px, 280px) minmax(0, 1fr); gap: 14px; align-items: start; }
.sbs-left { border-right: 3px solid #222226; padding-right: 14px; }
.h-res { color: var(--info); }
.h-act { color: var(--ok); }
.res-list td.slot { font-weight: 700; font-size: 1rem; font-variant-numeric: tabular-nums; }
.res-list td.theme { font-weight: 600; }
.res-list tr.soon td:first-child { box-shadow: inset 4px 0 0 var(--accent); }
@media (max-width: 900px) { .side-by-side { grid-template-columns: 1fr; } .sbs-left { border-right: 0; padding-right: 0; } }
.sbs-right td, .sbs-right th { white-space: nowrap; padding: 6px 6px; }
.sbs-right td.note { max-width: 140px; }

/* 商品明細欄寬固定，數字對齊 */
.records th.num { text-align: right; }
.records td.num { padding-right: 14px; }
.records th.num { padding-right: 14px; }

/* 網路預約／主題明細區塊加高（約兩倍），內容多時在框內捲動 */
.side-by-side { min-height: 560px; }
.side-by-side .table-wrap, .side-by-side .grid-wrap { max-height: 640px; overflow-y: auto; }
.res-list td, .sbs-right td { padding-top: 10px; padding-bottom: 10px; }

/* 各主題小計表 */
.summary { display: block; color: inherit; }
.sum-table { max-width: 720px; }
.sum-table td.theme { font-weight: 600; }

/* 網路預約／主題明細：固定高度，表格填滿到最下面，捲軸從頂到底 */
.side-by-side { height: 600px; min-height: 0; }
.sbs-left, .sbs-right { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.sbs-left > .grid-wrap, .sbs-right > .table-wrap { flex: 1; min-height: 0; max-height: none; overflow-y: auto; background: #121214; border: 1px solid var(--line); border-radius: 6px; }
@media (max-width: 900px) { .side-by-side { height: auto; } .sbs-left > .grid-wrap, .sbs-right > .table-wrap { max-height: 420px; } }
.amt-grid { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; color: var(--text); }
.amt-grid .amt-v { text-align: right; font-variant-numeric: tabular-nums; }
.amt-grid .amt-cash { color: var(--accent); font-size: 1.25rem; font-weight: 800; border-top: 1px solid var(--line); padding-top: 6px; }

/* 人數、金額欄位：數字置中、隱藏上下小箭頭 */
.stepper .num, input.num { text-align: center; -moz-appearance: textfield; appearance: textfield; }
input.num::-webkit-outer-spin-button, input.num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* 黑名單 */
.res-list tr.blacklisted td { color: #ff6b6b; background: var(--bad-bg); cursor: pointer; font-weight: 700; }
.badge.bad { background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad); }
.bl-res { color: var(--muted); margin-bottom: 4px; }
.bl-item { border: 1px solid var(--bad); background: var(--bad-bg); border-radius: 8px; padding: 10px 12px; margin-top: 10px; }
.bl-name { font-weight: 700; color: var(--bad); margin-bottom: 6px; }
.bl-flags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.bl-flags .badge { margin-left: 0; font-size: .85rem; padding: 2px 8px; }
.bl-remark { white-space: pre-wrap; }

/* 捲軸一直顯示（Mac / Windows 預設會隱藏） */
/* Firefox 用標準寫法；Chrome / Edge / Safari 用下面的 ::-webkit-scrollbar（兩者不能同時給 Chrome，否則自訂樣式會失效） */
@supports not selector(::-webkit-scrollbar) {
  .sbs-left > .grid-wrap, .sbs-right > .table-wrap, .cart { scrollbar-width: thin; scrollbar-color: var(--accent) transparent; }
}
.sbs-left > .grid-wrap::-webkit-scrollbar, .sbs-right > .table-wrap::-webkit-scrollbar, .cart::-webkit-scrollbar { width: 3px; height: 3px; }
.sbs-left > .grid-wrap::-webkit-scrollbar-track, .sbs-right > .table-wrap::-webkit-scrollbar-track, .cart::-webkit-scrollbar-track { background: transparent; }
.sbs-left > .grid-wrap::-webkit-scrollbar-thumb, .sbs-right > .table-wrap::-webkit-scrollbar-thumb, .cart::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 2px; min-height: 40px; }
.sbs-left > .grid-wrap::-webkit-scrollbar-thumb:hover, .sbs-right > .table-wrap::-webkit-scrollbar-thumb:hover { background: #ffe58a; }

/* 網路預約內容：淺灰色，比較好閱讀（黑名單仍為紅色） */
.res-list tbody td, .res-list tbody td.slot, .res-list tbody td.theme, .res-list tbody td.big-num { color: #75757d; }
.res-list tbody tr.blacklisted td { color: #ff6b6b; }

/* 設定頁：改過尚未儲存的列 */
.records.editable tr.dirty td { background: var(--warn-bg); }
.records.editable tr.dirty td:last-child .btn { box-shadow: 0 0 0 2px var(--warn); }

/* 設定頁上方固定的儲存列 */
.catalog-bar { position: sticky; top: 52px; z-index: 10; display: flex; align-items: center; gap: 12px; background: var(--bg); padding: 8px 0 12px; }
.catalog-bar .catalog-title { font-weight: 700; color: var(--accent); margin-right: auto; }
.catalog-bar .btn.primary { min-width: 120px; }

/* 人數／金額：滑鼠移上去時亮起數字欄位 */
.stepper .num:hover { border-color: var(--accent); }


/* 網路預約／主題明細：左右每一列等高，方便左右對照（2026-12-05） */
.side-by-side thead th { height: 38px; padding-top: 0; padding-bottom: 0; line-height: 1.2; }
.side-by-side tbody td { height: 44px; padding-top: 0 !important; padding-bottom: 0 !important; line-height: 1.2; white-space: nowrap; }
.side-by-side tbody td .btn, .side-by-side tbody td button { padding-top: 0; padding-bottom: 0; height: 28px; line-height: 26px; font-size: .8rem; vertical-align: middle; }
.side-by-side tbody td .badge { padding-top: 1px; padding-bottom: 1px; line-height: 1.2; vertical-align: middle; }
.side-by-side tfoot td { height: 40px; padding-top: 0; padding-bottom: 0; }
