/* Royal Bali SPA 櫃台 */
:root {
  --bg: #f5f2ec;
  --panel: #ffffff;
  --ink: #1f2b29;
  --muted: #5d6b68;
  --line: #d9d2c6;
  --line-soft: #ece7dd;
  --brand: #0f5c55;
  --brand-dark: #0a4640;
  --accent: #a45f12;
  --danger: #b3261e;
  --ok: #1a7350;
  --booking-bg: #dbf0ec; --booking-bd: #0f5c55;
  --billed-bg: #fdebc8; --billed-bd: #a45f12;
  --paid-bg: #e4e7e2; --paid-bd: #66756f;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(31, 43, 41, .12);
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Segoe UI", sans-serif;
  line-height: 1.45;
}
h2, h3 { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- 頂列 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 24px;
  padding: 0 20px; height: 54px; background: var(--brand); color: #fff;
}
.brand { font-weight: 700; font-size: 1.15rem; letter-spacing: .02em; white-space: nowrap; }
.brand-sub { margin-left: 8px; font-weight: 400; opacity: .85; font-size: .9rem; }
.tabs { display: flex; gap: 4px; height: 100%; }
.tabs a {
  display: flex; align-items: center; padding: 0 16px; color: #fff; text-decoration: none; opacity: .82;
  border-bottom: 3px solid transparent; border-top: 3px solid transparent; font-size: 1.02rem;
}
.tabs a:hover { opacity: 1; background: rgba(255, 255, 255, .08); }
.tabs a.active { opacity: 1; font-weight: 600; border-bottom-color: #f1c376; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: .88rem; white-space: nowrap; }
.test-badge { background: #f1c376; color: #3d2600; font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.clock { opacity: .9; font-variant-numeric: tabular-nums; }

main { padding: 16px 20px 40px; max-width: 1500px; margin: 0 auto; }
.loading, .empty { color: var(--muted); padding: 12px 0; margin: 0; }
.view > * + * { margin-top: 14px; }

/* ---------- 按鈕與輸入 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 14px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--brand-dark); color: #fff; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.accent:hover:not(:disabled) { background: #8a4f0d; color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn.danger:hover:not(:disabled) { background: #8f1d17; color: #fff; }
.btn.danger-outline { color: var(--danger); border-color: #e3b5b1; }
.btn.danger-outline:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); background: #fdf1f0; }
.btn.big { min-height: 46px; padding: 8px 22px; font-size: 1.08rem; }
.btn.small { min-height: 30px; padding: 3px 10px; font-size: .9rem; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after {
  content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid #9aa; border-top-color: transparent; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn {
  width: 32px; height: 32px; border: 0; border-radius: 6px; background: transparent; font-size: 1.3rem; line-height: 1;
  cursor: pointer; color: var(--muted);
}
.icon-btn:hover { background: var(--line-soft); color: var(--ink); }
.link { border: 0; background: none; padding: 0; color: var(--brand); text-decoration: underline; cursor: pointer; font-weight: 600; }
:focus-visible { outline: 2px solid #1a8f84; outline-offset: 2px; }

input[type="text"], input[type="tel"], input[type="date"], input[type="time"], input[type="number"], select, textarea {
  min-height: 36px; padding: 6px 9px; border: 1px solid #bdb5a8; border-radius: 6px; background: #fff; width: 100%; min-width: 0;
}
textarea { resize: vertical; }
input.money { text-align: right; font-variant-numeric: tabular-nums; width: 100px; }
input.narrow { width: 84px; }
input.invalid { border-color: var(--danger); background: #fdf1f0; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--brand); }
.check { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: .88rem; color: var(--muted); font-weight: 600; }
.field-hint, .hint { font-size: .86rem; color: var(--muted); }
.req { color: var(--danger); font-style: normal; margin-left: 2px; }
.form-grid { display: grid; gap: 12px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.section-head { display: flex; align-items: baseline; gap: 12px; margin: 16px 0 8px; }
.section-head h3 { font-size: 1rem; }
.row-actions { margin: 8px 0 12px; display: flex; gap: 8px; }
.spacer { flex: 1; }

.badge {
  display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .82rem; font-weight: 600; white-space: nowrap;
  background: var(--line-soft); color: var(--ink); border: 1px solid var(--line);
}
.badge.ok { background: #d9f0e4; border-color: #9ccfb5; color: #0f5236; }
.badge.booking { background: var(--booking-bg); border-color: #8cc5bc; color: #0a4640; }
.badge.billed { background: var(--billed-bg); border-color: #e2b877; color: #6b3d06; }
.badge.paid { background: var(--paid-bg); border-color: #b3bdb7; color: #36423d; }
.badge.muted { color: var(--muted); }
.badge.test { background: #fff0cc; border-color: #e6c36f; color: #5a3c00; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- 工具列 ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.date-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.date-nav .date-input { width: auto; }
.date-label { font-size: 1.15rem; margin-left: 4px; }
.toolbar-actions { display: flex; gap: 10px; }
.legend { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; font-size: .9rem; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-hint { color: var(--muted); margin-left: auto; }
.swatch { width: 14px; height: 14px; border-radius: 3px; border-left: 4px solid; display: inline-block; }
.swatch.booking { background: var(--booking-bg); border-color: var(--booking-bd); }
.swatch.billed { background: var(--billed-bg); border-color: var(--billed-bd); }
.swatch.paid { background: var(--paid-bg); border-color: var(--paid-bd); }

/* ---------- 時段表 ---------- */
.sched-scroll {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  max-height: calc(100vh - 250px); min-height: 320px; overflow: auto; position: relative;
}
.sched-head { display: grid; position: sticky; top: 0; z-index: 5; background: #faf8f4; border-bottom: 1px solid var(--line); }
.sched-th { padding: 8px 10px; border-left: 1px solid var(--line); display: flex; align-items: baseline; gap: 8px; }
.th-code { font-weight: 700; color: var(--brand); }
.th-name { font-weight: 600; }
.sched-body { display: grid; position: relative; padding-top: 10px; padding-bottom: 10px; }
.sched-time { position: relative; }
.time-label {
  position: absolute; right: 8px; transform: translateY(-50%); font-size: .8rem; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.sched-col {
  position: relative; border-left: 1px solid var(--line); cursor: copy;
  background-image:
    linear-gradient(to bottom, var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line-soft) 1px, transparent 1px);
}
.slot-hover {
  display: none; position: absolute; left: 2px; right: 2px; border-radius: 4px; pointer-events: none;
  background: rgba(15, 92, 85, .12); border: 1px dashed var(--brand); color: var(--brand-dark);
  font-size: .8rem; font-weight: 600; padding: 0 6px; line-height: 1.5; overflow: hidden;
}
.block {
  position: absolute; display: flex; flex-direction: column; align-items: stretch; gap: 1px; text-align: left;
  padding: 3px 7px; border: 1px solid; border-left-width: 5px; border-radius: 5px; overflow: hidden; cursor: pointer;
  font-size: .86rem; line-height: 1.3; color: var(--ink);
}
.block:hover { filter: brightness(.96); box-shadow: 0 2px 6px rgba(0, 0, 0, .18); z-index: 2; }
.block.booking { background: var(--booking-bg); border-color: var(--booking-bd); }
.block.billed { background: var(--billed-bg); border-color: var(--billed-bd); }
.block.paid { background: var(--paid-bg); border-color: var(--paid-bd); color: #36423d; }
.block.overlapped { border-style: dashed; border-left-style: solid; }
.block-line { display: flex; gap: 6px; white-space: nowrap; overflow: hidden; }
.block-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.block-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.block-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.block-tags { display: flex; gap: 6px; flex-wrap: wrap; font-size: .78rem; overflow: hidden; }
.block-status { font-weight: 600; opacity: .85; }
.block-tag { border: 1px solid currentColor; border-radius: 3px; padding: 0 4px; }
.block-tag.warn { color: var(--danger); font-weight: 700; }
.block-note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-style: italic; }
.block.compact { flex-direction: row; gap: 8px; align-items: center; padding-top: 0; padding-bottom: 0; }
.block.compact .block-tags { display: none; }
.now-line { position: absolute; left: 56px; right: 0; border-top: 2px solid #c8372d; pointer-events: none; z-index: 3; margin-top: 10px; }
.now-tag {
  position: absolute; left: -52px; top: -10px; background: #c8372d; color: #fff; font-size: .74rem; padding: 0 5px;
  border-radius: 3px; font-variant-numeric: tabular-nums;
}

/* ---------- 卡片與表格 ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.card-title { font-size: 1.05rem; margin-bottom: 10px; }
.error-card { border-color: #e3b5b1; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .85rem; color: var(--muted); font-weight: 600; padding: 6px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
.table td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.table.compact td { padding: 5px 8px; vertical-align: middle; }
.table .actions { white-space: nowrap; text-align: right; }
.table .actions .btn + .btn { margin-left: 6px; }
.table th.num, .table td.num { text-align: right; }
.row-cancelled td { color: #8a938f; text-decoration: line-through; }
.row-cancelled td:last-child, .row-cancelled td .badge { text-decoration: none; }
.total-row td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: 0; background: #faf8f4; }
.item-lines > div + div { margin-top: 2px; }
.plain-list { margin: 0; padding: 0; list-style: none; }
.plain-list li + li { margin-top: 4px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); }
.stat-label { font-size: .85rem; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.stat.main { background: var(--brand); border-color: var(--brand); color: #fff; }
.stat.main .stat-label { color: #cfe6e2; }
.stat.main .stat-value { font-size: 1.6rem; }
.stat.warn { background: var(--billed-bg); border-color: #e2b877; }

/* ---------- 對話框 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(20, 28, 26, .45);
  display: flex; align-items: flex-start; justify-content: center; padding: 4vh 16px; overflow-y: auto;
}
.modal { background: var(--panel); border-radius: 10px; box-shadow: 0 12px 40px rgba(0, 0, 0, .3); width: 100%; max-width: 620px; }
.modal.sm { max-width: 480px; }
.modal.lg { max-width: 860px; }
.modal.xl { max-width: 1080px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 12px 20px; border-bottom: 1px solid var(--line); }
.modal-title { font-size: 1.15rem; }
.modal-body { padding: 16px 20px; }
.modal-footer { display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--line); background: #faf8f4; border-radius: 0 0 10px 10px; }
.modal-footer:empty { display: none; }
.confirm-list { margin: 0; padding-left: 20px; }
.confirm-list li + li { margin-top: 6px; }
.confirm-list li:last-child { list-style: none; margin-left: -20px; margin-top: 12px; font-weight: 600; }

.detail { display: grid; grid-template-columns: 88px 1fr; gap: 8px 12px; margin: 0; }
.detail dt { color: var(--muted); font-weight: 600; font-size: .9rem; }
.detail dd { margin: 0; }
.detail.inline { grid-template-columns: repeat(3, auto 1fr); margin-bottom: 12px; }

/* 預約表單的療程列 */
.item-row { border: 1px solid var(--line-soft); border-radius: 6px; padding: 8px; background: #fcfbf8; }
.item-row + .item-row { margin-top: 8px; }
.item-row-main { display: grid; grid-template-columns: 24px 1.2fr 148px 2fr 128px 62px 32px; gap: 8px; align-items: center; }
.item-row-main .who { display: flex; gap: 6px; min-width: 0; }
.item-row-main .who select { flex: 1; min-width: 0; }
.modal.lg { max-width: 980px; }
.note-flag.soft { background: var(--line-soft); color: var(--muted); }
.item-no { font-weight: 700; color: var(--muted); text-align: center; }
.item-end { font-size: .86rem; color: var(--muted); white-space: nowrap; }
.item-row-hint { margin: 6px 0 0 32px; font-size: .85rem; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; }
.note-flag { color: #7a4a00; background: #fff0cc; border-radius: 4px; padding: 0 6px; }
.warn-box { border: 1px solid #e2b877; background: #fff6e0; color: #5a3600; border-radius: 6px; padding: 8px 12px; margin: 4px 0 12px; }
.warn-box ul { margin: 4px 0 0; padding-left: 20px; }
.notice { border-left: 4px solid #e2b877; background: #fff6e0; color: #5a3600; padding: 8px 12px; border-radius: 4px; margin: 0 0 12px; font-size: .92rem; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 3px 12px; cursor: pointer; font-size: .9rem; }
.chip:hover { border-color: var(--brand); color: var(--brand); }

/* 帳單 */
.order-meta { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; font-size: .92rem; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px dashed var(--line); }
.oi-row { display: grid; grid-template-columns: 24px 1.6fr 1.3fr 1fr 128px 104px 104px 54px 32px; gap: 8px; align-items: center; padding: 5px 0; }
.oi-head { font-size: .84rem; color: var(--muted); font-weight: 600; border-bottom: 2px solid var(--line); padding-bottom: 6px; }
.oi-row .money { width: 100%; }
.list-price { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.list-price small { font-size: .72rem; color: #7a4a00; }
.check-cell { display: flex; justify-content: center; }
.total-line { display: flex; justify-content: flex-end; align-items: baseline; gap: 16px; margin: 10px 0 4px; font-size: 1.05rem; }
.total-line strong { font-size: 1.7rem; font-variant-numeric: tabular-nums; min-width: 130px; text-align: right; }
.pay-panel { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-top: 12px; background: #fcfbf8; }
.pay-panel h3 { font-size: 1rem; margin-bottom: 8px; }
.pay-line { display: grid; grid-template-columns: 124px 110px auto 1fr; gap: 10px; align-items: center; padding: 4px 0; }
.pay-label { font-weight: 600; }
.pay-extra { display: flex; align-items: center; gap: 10px; }
.pay-extra input[type="text"]:not(.money) { max-width: 260px; }
.change { font-weight: 600; color: var(--ok); white-space: nowrap; }
.balance { margin: 10px 0 6px; padding: 8px 12px; border-radius: 6px; font-weight: 700; font-variant-numeric: tabular-nums; }
.balance.bad { background: #fdf1f0; color: #8f1d17; border: 1px solid #e3b5b1; }
.balance.good { background: #e3f3ea; color: #0f5236; border: 1px solid #9ccfb5; }

/* 小票預覽 */
.receipt-controls { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.receipt-controls select { width: auto; }
.receipt-stage { background: #e9e6e0; border-radius: 6px; padding: 16px; display: flex; justify-content: center; max-height: 62vh; overflow: auto; }
.receipt-frame { border: 0; background: #fff; box-shadow: 0 1px 6px rgba(0, 0, 0, .25); height: 300px; flex: none; }

/* 設定 */
.svc-card { border: 1px solid var(--line-soft); border-radius: 6px; padding: 10px; margin-bottom: 10px; background: #fcfbf8; }
.svc-card.inactive { opacity: .6; }
.svc-head { display: grid; grid-template-columns: 1.2fr 1.4fr 1fr 1fr auto auto; gap: 8px; align-items: center; }
.svc-code { font-size: .78rem; color: var(--muted); font-family: ui-monospace, Menlo, monospace; }
.table.options { margin: 8px 0 0 12px; width: auto; }
.table.options td { border-bottom: 0; white-space: nowrap; }
.table.options input.narrow, .table.options input.money { display: inline-block; }
.add-row td { background: #f6f3ec; }
.inline-form { display: grid; grid-template-columns: 1fr 1.3fr auto auto; gap: 8px; align-items: center; margin-top: 12px; }
.inline-form.extra-minute { display: flex; flex-wrap: wrap; margin: 0 0 12px; }
.cat-block { border: 1px solid var(--line); border-radius: 6px; margin-bottom: 8px; background: #fff; }
.cat-block > summary { padding: 10px 12px; cursor: pointer; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.cat-block[open] > summary { border-bottom: 1px solid var(--line-soft); margin-bottom: 8px; }
.cat-block .svc-card { margin: 0 10px 10px; }

/* ---------- 第二輪：分鐘快捷鍵、派工標籤 ---------- */
.small { font-size: .84rem; }
.badge.requested { background: #efe3fb; border-color: #c9a9ea; color: #4a1f78; }
.badge.working { background: #fbdcd9; border-color: #e09a94; color: #7d1610; }
.badge.done { background: #fbf0bf; border-color: #dcc25c; color: #5c4700; }
.sync { font-size: .82rem; opacity: .9; display: inline-flex; align-items: center; gap: 6px; }
.sync::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #7be0a8; }
.sync.down::before { background: #f1c376; }

.dur-picker { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0 0 32px; }
.dur-label { font-size: .86rem; color: var(--muted); font-weight: 600; }
.dur-btn {
  border: 1px solid #bdb5a8; background: #fff; border-radius: 6px; padding: 4px 12px; cursor: pointer; min-height: 34px;
  font-variant-numeric: tabular-nums;
}
.dur-btn:hover { border-color: var(--brand); }
.dur-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.dur-btn.base { border-color: var(--brand); border-style: dashed; box-shadow: inset 0 0 0 1px var(--brand); }
.dur-custom-btn { font-weight: 600; }
.dur-custom { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--muted); }
.dur-custom input { width: 76px; }
.oi-block { border-bottom: 1px solid var(--line-soft); padding: 4px 0 8px; }
.oi-block .item-row-hint { align-items: center; }
/* 開單表單：這筆預計派給誰 */
.dispatch-preview:empty { display: none; }
.dispatch-preview { color: var(--ink, #1f2b29); flex-basis: 100%; }
.dispatch-preview strong { font-weight: 700; }

/* 時段表：未指定欄、上工中 */
.sched-th.unassigned { background: #f3efe6; }
.sched-th.unassigned .th-code { color: var(--accent); }
.sched-col.unassigned { background-color: #faf7f0; }
.block.is-working { box-shadow: inset 0 0 0 2px #c8372d; }
.block-tag.job-working { color: #a3211a; font-weight: 700; }
.block-tag.job-done { color: #6b5300; font-weight: 700; }

/* ---------- 即時排位 ---------- */
.next-up { margin-left: 12px; padding: 4px 12px; border-radius: 999px; background: #dbf0ec; border: 1px solid #8cc5bc; }
.next-up.none { background: var(--billed-bg); border-color: #e2b877; }
.q-dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; border: 2px solid; }
.q-dot.waiting { background: #f2d24b; border-color: #b89a16; }
.q-dot.working { background: #d9443a; border-color: #a3211a; }
.q-dot.green { background: #3fae6a; border-color: #1f7a43; }
.job-list { display: flex; flex-direction: column; gap: 8px; }
.job-row {
  display: grid; grid-template-columns: minmax(260px, 1.2fr) minmax(200px, 1.4fr) auto; gap: 12px; align-items: center;
  border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: 6px; padding: 8px 12px; background: #fffaf0;
}
.job-row.assigned { border-left-color: var(--brand); background: #f4faf8; }
.job-row.working { border-left-color: #d9443a; background: #fdf0ef; }
.job-state { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .92rem; }
.job-link { font-weight: 600; }
.job-time { font-variant-numeric: tabular-nums; }
.job-svc { white-space: nowrap; }
.timing { font-size: .9rem; color: #7d1610; font-variant-numeric: tabular-nums; }
.timing.over strong { background: #d9443a; color: #fff; border-radius: 4px; padding: 0 6px; }
.job-main { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.job-next { font-size: .9rem; color: var(--muted); white-space: nowrap; }
.job-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.assign-select { width: auto; min-width: 130px; }
.warn-text { color: var(--danger); font-weight: 600; }
.q-list { display: flex; flex-direction: column; gap: 8px; }
.q-card { border: 1px solid #dcc25c; border-left: 8px solid #f2d24b; border-radius: 8px; padding: 8px 12px; background: #fffbe6; }
.q-card.state-working { border-color: #e09a94; border-left-color: #d9443a; background: #fdf0ef; }
.q-card.state-green { border-color: #9bd0ad; border-left-color: #3fae6a; background: #ecf8ef; }
.q-card.state-off { border-color: var(--line); border-left-color: var(--line); background: #faf8f4; }
.q-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.q-pos {
  width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: #fff; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums;
}
.q-name { font-size: 1.08rem; }
.q-state { padding: 2px 12px; border-radius: 999px; font-weight: 700; font-size: .9rem; border: 1px solid; }
.q-state.waiting { background: #f2d24b; border-color: #b89a16; color: #3d3000; }
.q-state.working { background: #d9443a; border-color: #a3211a; color: #fff; }
.q-state.green { background: #3fae6a; border-color: #1f7a43; color: #fff; }
.q-green-note { font-size: .88rem; color: #1b5e34; font-weight: 600; }
.q-green-note.over { color: #8a4f0d; }
.next-up.green { background: #ecf8ef; border-color: #9bd0ad; color: #1b5e34; }
.badge.green { background: #dff3e5; color: #1b5e34; border-color: #9bd0ad; }
.btn.to-tail { white-space: nowrap; }
.q-state.off { background: var(--line-soft); border-color: var(--line); color: var(--muted); }
.q-current { margin-top: 8px; padding: 8px 10px; border-radius: 6px; background: rgba(255, 255, 255, .7); border: 1px dashed #e09a94; display: grid; gap: 6px; }
.q-pending .q-job { border-top: 1px dashed rgba(0, 0, 0, .12); }

/* 獨立視窗：只留排位畫面 */
body.standalone .tabs { display: none; }
body.standalone main { max-width: none; }
.q-current-time { font-size: .9rem; color: #7d1610; font-variant-numeric: tabular-nums; }
.q-pending, .q-done { margin-top: 8px; }
.q-sub { font-size: .84rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.q-empty { margin: 6px 0 0; font-size: .88rem; color: var(--muted); }
.q-job { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 4px 0; }
.q-job-text { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.q-job-actions { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.q-done summary { cursor: pointer; font-size: .88rem; color: var(--muted); }
details > summary.card-title { cursor: pointer; margin-bottom: 0; }
details[open] > summary.card-title { margin-bottom: 10px; }

/* ---------- 抽成 ---------- */
input.pct { width: 70px; text-align: right; font-variant-numeric: tabular-nums; }
.table.matrix th[scope="row"] { text-align: left; font-size: .95rem; color: var(--ink); }
.table.matrix td, .table.matrix th { white-space: nowrap; }
.table.matrix thead th { vertical-align: bottom; white-space: normal; min-width: 96px; }

/* ---------- 提示訊息 ---------- */
/* 放在上方中間，才不會蓋住對話框右下角的「確認收款」等按鈕 */
#toast-root { position: fixed; left: 50%; top: 64px; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #1f2b29; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); max-width: 420px; transition: opacity .3s; }
.toast.error { background: var(--danger); }
.toast.warn { background: #7a4a00; }
.toast.leaving { opacity: 0; }

/* ---------- 客人、舊系統資料 ---------- */
.legacy-note { margin: 0 0 10px; padding: 6px 10px; border-radius: 6px; background: var(--line-soft); color: var(--muted); font-size: .9rem; }
.legacy-status p { margin: 0 0 8px; }
#cust-q { min-width: 280px; }
.cust-search { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }

/* ---------- 指定男／女師傅 ---------- */
.badge.gender { background: #e3eefc; border-color: #9dbbe6; color: #17407a; }
.gender-fixed { display: inline-flex; align-items: center; padding: 6px 10px; border: 1px dashed #9dbbe6; border-radius: 6px; background: #f2f7fe; color: #17407a; font-size: .92rem; white-space: nowrap; }
.gender-avail { font-size: .88rem; color: #17407a; font-weight: 600; }
.gender-avail.warn-text { color: var(--danger); }
select.sel-gender { width: 76px; }

/* ---------- 服務段（換師傅／套餐分段） ---------- */
.seg-chain { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; font-size: .9rem; }
.job-row .seg-chain { grid-column: 1 / -1; }
.q-job.has-segments .seg-chain { flex-basis: 100%; }
.seg {
  display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 3px 10px; border-radius: 6px;
  border: 1px solid var(--line); background: #fff;
}
.seg-no { color: var(--muted); font-size: .84rem; }
.seg-min { font-weight: 700; font-variant-numeric: tabular-nums; }
.seg-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.seg-state { font-size: .82rem; padding: 0 6px; border-radius: 999px; border: 1px solid transparent; }
.seg-done { background: #f3f6f4; }
.seg-done .seg-state { background: #e3ebe6; color: #36423d; }
.seg-working { border-color: #e09a94; background: #fdf0ef; }
.seg-working .seg-state { background: #d9443a; color: #fff; }
.seg-waiting, .seg-unassigned { border-color: #c9a9ea; background: #f7f0fd; border-style: dashed; }
.seg-waiting .seg-state, .seg-unassigned .seg-state { background: #6b3fa0; color: #fff; }
.seg-planned { border-style: dashed; }
.seg-planned .seg-state { background: var(--line-soft); color: var(--muted); }
.seg-arrow { color: var(--muted); }
.badge.handover { background: #6b3fa0; border-color: #4a1f78; color: #fff; }
.handover-wait { display: inline-flex; align-items: center; gap: 4px; color: #4a1f78; font-weight: 600; }
.job-row.handover-waiting { border-left-color: #6b3fa0; background: #faf5ff; }
.seg-box { margin: 6px 0 0 32px; padding: 8px 10px; border: 1px dashed #c9a9ea; border-radius: 6px; background: #faf5ff; }
.seg-box-title { font-weight: 600; font-size: .92rem; }
td .seg-chain { font-size: .86rem; }
/* 換師傅對話框 */
.ho-what { margin: 0 0 8px; }
.ho-when { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.ho-choice { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.ho-choice.on { border-color: var(--brand); background: #eef7f5; }
.ho-choice small { display: block; color: var(--muted); }
.ho-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 12px 0 6px; }
.ho-min { display: inline-flex; align-items: center; gap: 6px; }
.ho-to { margin: 12px 0 8px; }

/* 程式更新提示：蓋在所有對話框之上，櫃台存好資料後自己按重新整理 */
#update-bar {
  position: fixed; left: 16px; right: 16px; bottom: 18px; margin: 0 auto; width: fit-content; max-width: 760px; z-index: 90;
  display: flex; align-items: center; gap: 14px;
  background: #fff6e0; color: #5a3600; border: 2px solid var(--accent); border-radius: 10px;
  padding: 10px 14px 10px 18px; font-weight: 600; box-shadow: 0 6px 24px rgba(0, 0, 0, .28);
}
#update-bar span { min-width: 0; }
#update-bar .btn { flex: none; }
/* 提示出現時，頁面和對話框底部多留空間，往下捲就能把按鈕捲到提示上方 */
body.has-update main { padding-bottom: 120px; }
body.has-update .overlay { padding-bottom: 120px; }

@media (max-width: 900px) {
  .form-grid.three { grid-template-columns: 1fr; }
  .job-row { grid-template-columns: 1fr; }
  .dur-picker { margin-left: 0; }
  .item-row-main { grid-template-columns: 24px 1fr 1fr; }
  .oi-row { grid-template-columns: 24px 1fr 1fr 1fr; }
  .oi-head { display: none; }
  .svc-head { grid-template-columns: 1fr 1fr; }
  .table.options { margin-left: 0; }
  .legend-hint { margin-left: 0; }
  .topbar { gap: 10px; padding: 0 10px; }
  .clock { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .btn.busy::after { animation: none; }
  .toast { transition: none; }
}

/* 排位頁：休假／已下班放在排位表最上面；報到只是紀錄 */
.q-off-top { margin: 0 0 12px; padding: 8px 10px; border: 1px dashed var(--line, #d9d4c8); border-radius: 8px; background: var(--line-soft, #f4f1ea); }
.q-off-top .q-list.off { margin-top: 6px; }
.q-state.off.leave { background: #e8e2f3; color: #4a3a78; }
.q-not-arrived { font-size: .8rem; color: #7a4a00; background: #fff0cc; border-radius: 4px; padding: 0 6px; }
/* 班表 */
.roster-nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.roster-table th.roster-day { text-align: center; white-space: nowrap; font-weight: 600; }
.roster-table th.roster-day.today { background: #fff6dc; }
.roster-table th.roster-day.past { color: var(--muted); }
.roster-count { font-size: .78rem; font-weight: 400; color: var(--muted); }
.roster-table th.roster-name { text-align: left; white-space: nowrap; font-weight: 600; }
.roster-table td { text-align: center; padding: 4px; }
.roster-cell { min-width: 64px; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--line, #d9d4c8); background: #eef7f1; color: #17603f; cursor: pointer; font: inherit; }
.roster-cell.off { background: #e8e2f3; color: #4a3a78; border-color: #cbbfe6; font-weight: 600; }
.roster-cell:disabled { opacity: .55; cursor: default; }

/* 今日預約：上班人數、名額試算 */
.staff-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 0 0 10px; padding: 8px 12px; background: var(--card, #fff); border: 1px solid var(--line, #d9d4c8); border-radius: 8px; }
.staff-bar .staff-off { color: #4a3a78; background: #e8e2f3; border-radius: 4px; padding: 0 8px; font-size: .9rem; }
.staff-bar .spacer { flex: 1; }
.cap-switch { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: .9rem; color: var(--muted); }
.cap-custom { width: 72px; padding: 4px 6px; }
.sched-th .th-cap { display: block; font-size: .72rem; font-weight: 400; color: var(--muted); }
.cap-cell { position: absolute; right: 3px; z-index: 1; display: flex; flex-direction: column; justify-content: center; gap: 1px; padding: 2px 6px; border: 1px solid #cfe5d6; border-radius: 6px; background: #f1f9f3; color: #17603f; font: inherit; font-size: .72rem; line-height: 1.25; text-align: left; cursor: pointer; overflow: hidden; white-space: nowrap; }
.cap-cell:hover { border-color: #17603f; }
.cap-cell .cap-time { color: var(--muted); }
.cap-cell .cap-any { font-weight: 700; }
.cap-cell .cap-gender .no { color: #a13a2e; font-weight: 600; }
.cap-cell.full { background: #fdeeee; border-color: #efc4be; color: #a13a2e; }
.cap-cell.past { opacity: .45; }
/* 預約表單：可排／排不下 */
.cap-result { flex-basis: 100%; font-weight: 600; }
.cap-result:empty { display: none; }
.cap-result.ok { color: #17603f; }
.cap-result.bad { color: var(--danger); }

/* 時段表：這天休假或已下班的師傅 */
.sched-th .th-away { margin-left: 8px; font-size: .78rem; font-weight: 600; color: #4a3a78; background: #e8e2f3; border-radius: 4px; padding: 0 8px; }
.sched-th.away .th-code, .sched-th.away .th-name { color: var(--muted); }
.sched-col.away { background-image: repeating-linear-gradient(135deg, rgba(74, 58, 120, .07) 0 8px, transparent 8px 16px) !important; background-size: auto !important; }
.staff-bar .cap-switch { flex-wrap: nowrap; white-space: nowrap; }
.staff-bar .cap-switch input.cap-custom { width: 76px; flex: 0 0 76px; min-width: 0; padding: 4px 6px; }

/* 右上角：目前收款人 */
.who-btn { display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px; border-radius: 999px; border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.12); color: #fff; font: inherit; font-size: .9rem; cursor: pointer; }
.who-btn.none { background: #f3c86b; color: #3b2a00; border-color: #f3c86b; font-weight: 700; }
.who-btn .who-role { font-size: .75rem; opacity: .8; }
.who-btn .who-shift { font-size: .8rem; opacity: .85; }
/* 收款面板上的收款人 */
.collector { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 0 0 8px; padding: 6px 10px; border-radius: 6px; background: #eef7f1; }
/* 我的當班／全店日結 */
.desk-card { border-left: 4px solid #17603f; }
.desk-stats .stat-value.small { font-size: 1rem; }
.desk-cash-split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: end; margin: 10px 0; padding: 10px 12px; background: var(--line-soft, #f4f1ea); border-radius: 8px; }
.desk-cash-split strong { display: block; font-size: 1.4rem; }
.desk-unpaid li { margin: 2px 0; }
.desk-history { margin-top: 10px; }
.desk-facts { line-height: 1.7; }

.desk-cash-split input.money { width: 100%; max-width: 220px; }
.acc-owner-only { align-self: center; margin: 0; }

/* 查單與補印紀錄 */
#access-log-table tr.row-warn td { background: #fdf3f1; }

/* 第十二輪：今日帳目的折扣與彙總（老闆） */
#acc-finance-wrap .stats { margin-top: 10px; }
#acc-finance-wrap .hint { margin: 6px 0 0; }
.acc-finance .stat.acc-remaining { border-color: var(--brand); border-width: 2px; }
.acc-finance .stat.acc-remaining .stat-value { color: var(--brand); }
.acc-discount { white-space: nowrap; font-weight: 400; }
.acc-range-form { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.acc-range-form label { display: inline-flex; gap: 6px; align-items: center; }
.acc-range-head { margin: 8px 0; font-weight: 600; }
#acc-range-result .table-wrap { margin-top: 10px; }
