/* ===== 色彩與基礎 ===== */
:root {
  --red: #9b1c1c;
  --red-dark: #7a1414;
  --red-soft: #f8e6e3;
  --gold: #c8932e;
  --gold-soft: #f6e7c4;
  --paper: #fbf6ec;
  --bg: #fffdf8;
  --card: #ffffff;
  --ink: #2a1f1a;
  --muted: #6b5d55;
  --line: #e4d6bf;
  --ok: #2f7a3e;
  --ok-soft: #e4f3e6;
  --warn: #9a6a00;
  --warn-soft: #fff4d6;
  --err: #b3261e;
  --err-soft: #fdeceb;
  --info-soft: #eef3f8;
  --info: #2c4a6b;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(80, 40, 20, .08);
  --serif: "Noto Serif TC", "PMingLiU", serif;
  --sans: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.7;
  color: var(--ink);
  background: var(--bg);
}
img { max-width: 100%; }
a { color: var(--red); }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ===== 模擬提示列 ===== */
.demo-banner {
  background: #3a2a20;
  color: #fbe9c6;
  font-size: 14px;
  padding: 8px 16px;
  text-align: center;
}
.demo-banner strong { color: #fff; }

/* ===== 頁首 ===== */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--red);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 64px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand-seal {
  width: 42px; height: 42px; flex: none;
  display: grid; place-items: center;
  border: 2px solid var(--gold-soft); border-radius: 8px;
  font-family: var(--serif); font-weight: 900; font-size: 22px;
  background: var(--red-dark); color: var(--gold-soft);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-family: var(--serif); font-weight: 700; font-size: 18px; }
.brand-sub { font-size: 13px; opacity: .85; }
.site-nav { display: flex; gap: 4px; }
.site-nav a {
  color: #fff; text-decoration: none; padding: 8px 14px; border-radius: 8px; font-weight: 500;
}
.site-nav a:hover, .site-nav a:focus-visible { background: rgba(255,255,255,.15); }
.nav-toggle {
  display: none;
  background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.5);
  border-radius: 8px; padding: 6px 14px; font: inherit; font-size: 15px; cursor: pointer;
}

/* ===== 主視覺 ===== */
.hero {
  background:
    radial-gradient(circle at 85% 10%, rgba(200,147,46,.25), transparent 45%),
    linear-gradient(160deg, var(--red-dark), var(--red) 60%, #b3402a);
  color: #fff;
  padding: 56px 0 64px;
  text-align: center;
}
.hero-kicker { margin: 0; color: var(--gold-soft); letter-spacing: .1em; font-size: 15px; }
.hero h1 {
  font-family: var(--serif); font-weight: 900;
  font-size: clamp(34px, 7vw, 56px); line-height: 1.25; margin: 8px 0 8px;
  letter-spacing: .06em;
}
.br-sm { display: none; }
.hero-date { margin: 0 0 28px; font-size: 18px; }
.quota-card {
  max-width: 460px; margin: 0 auto 28px;
  background: rgba(255,255,255,.96); color: var(--ink);
  border-radius: var(--radius); padding: 16px 20px; text-align: left;
  box-shadow: 0 6px 20px rgba(0,0,0,.18);
}
.quota-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 500; }
.quota-num strong { font-size: 26px; color: var(--red); font-family: var(--serif); }
.quota-bar { height: 12px; background: #efe5d4; border-radius: 99px; overflow: hidden; margin: 8px 0 6px; }
.quota-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--red)); transition: width .5s; }
.quota-note { margin: 0; font-size: 14px; color: var(--muted); }
.quota-note.full { color: var(--err); font-weight: 700; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero .btn-ghost { color: #fff; border-color: rgba(255,255,255,.7); background: transparent; }
.hero .btn-ghost:hover { background: rgba(255,255,255,.12); }

/* ===== 按鈕 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 8px 20px;
  font: inherit; font-weight: 700; font-size: 16px;
  border-radius: 10px; border: 2px solid transparent;
  cursor: pointer; text-decoration: none; transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-lg { min-height: 52px; padding: 10px 28px; font-size: 18px; }
.btn-sm { min-height: 38px; padding: 4px 14px; font-size: 14px; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--red-dark); }
.hero .btn-primary { background: var(--gold); color: #2a1f1a; }
.hero .btn-primary:hover { background: #dba84a; }
.btn-ghost { background: #fff; color: var(--red); border-color: var(--red); }
.btn-ghost:hover:not(:disabled) { background: var(--red-soft); }
.btn-danger { background: #fff; color: var(--err); border-color: var(--err); }
.btn-danger:hover:not(:disabled) { background: var(--err-soft); }
.btn-ok { background: var(--ok); color: #fff; }
.btn:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ===== 區塊 ===== */
.section { padding: 56px 0; }
.section-paper { background: var(--paper); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-title {
  font-family: var(--serif); font-size: 28px; text-align: center; margin: 0 0 24px; color: var(--red);
}
.section-title span { display: inline-block; padding: 0 18px; position: relative; }
.section-title span::before, .section-title span::after {
  content: ""; position: absolute; top: 50%; width: 32px; height: 2px; background: var(--gold);
}
.section-title span::before { right: 100%; }
.section-title span::after { left: 100%; }
.section-lead { text-align: center; color: var(--muted); margin: -8px 0 24px; }
.sub-title { font-family: var(--serif); color: var(--red); font-size: 21px; margin: 32px 0 12px; }

.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.info-card {
  background: var(--card); border: 1px solid var(--line); border-top: 4px solid var(--red);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
}
.info-card h3 { margin: 0 0 4px; font-size: 15px; color: var(--muted); font-weight: 500; }
.info-card p { margin: 0; font-size: 18px; font-weight: 500; }
.info-card small { color: var(--muted); font-size: 13px; font-weight: 400; }

.price-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.price-card {
  background: var(--gold-soft); border-radius: var(--radius); padding: 18px 20px; border: 1px solid #e8cf98;
}
.price-card-alt { background: var(--red-soft); border-color: #ebc3bd; }
.price-name { margin: 0; font-weight: 700; }
.price-amount { margin: 4px 0; font-family: var(--serif); font-size: 34px; font-weight: 900; color: var(--red); line-height: 1.2; }
.price-amount small { font-size: 15px; color: var(--muted); font-family: var(--sans); font-weight: 400; margin-left: 4px; }
.price-desc { margin: 0; font-size: 15px; color: var(--muted); }

.fee-table { width: 100%; max-width: 420px; margin: 20px 0 0; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; }
.fee-table caption { text-align: left; font-weight: 700; padding-bottom: 6px; }
.fee-table th, .fee-table td { padding: 8px 14px; border-bottom: 1px solid var(--line); text-align: left; }
.fee-table td:last-child, .fee-table th:last-child { text-align: right; }
.fee-table thead th { background: var(--paper); font-size: 15px; }
.fee-table tfoot th { color: var(--red); font-size: 18px; border-bottom: 0; }

.notice-list { margin: 24px 0 0; padding: 16px 20px 16px 40px; background: var(--paper); border-left: 4px solid var(--gold); border-radius: 8px; }
.notice-list li { margin: 4px 0; }

/* ===== 表單 ===== */
.form { max-width: 760px; margin: 0 auto; }
fieldset {
  border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
  padding: 16px 20px 8px; margin: 0 0 20px; box-shadow: var(--shadow); min-width: 0;
}
legend {
  font-family: var(--serif); font-weight: 700; color: var(--red); font-size: 19px;
  padding: 0 8px; background: #fff; border-radius: 6px;
}
.field { margin-bottom: 14px; min-width: 0; }
.field label, .field .label { display: block; font-weight: 500; margin-bottom: 4px; }
.req { color: var(--err); }
input[type="text"], input[type="tel"], input[type="number"], input[type="search"], input[type="date"], select {
  width: 100%; min-height: 48px; padding: 8px 12px;
  font: inherit; font-size: 17px; color: var(--ink);
  border: 1.5px solid #cbbba3; border-radius: 8px; background: #fff;
}
input.upper { text-transform: uppercase; }
input.invalid, select.invalid { border-color: var(--err); background: var(--err-soft); }
.hint { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.err { margin: 4px 0 0; font-size: 15px; color: var(--err); font-weight: 500; min-height: 0; }
.err:empty { display: none; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 0 16px; }

.choice-row { display: flex; gap: 12px; flex-wrap: wrap; }
.choice {
  display: inline-flex !important; align-items: center; gap: 8px;
  min-height: 48px; padding: 6px 18px; border: 1.5px solid #cbbba3; border-radius: 8px;
  cursor: pointer; background: #fff; font-weight: 400 !important;
}
.choice:has(input:checked) { border-color: var(--red); background: var(--red-soft); font-weight: 700 !important; }
.choice input { width: 20px; height: 20px; accent-color: var(--red); margin: 0; flex: none; }
.choice-block { display: flex !important; align-items: flex-start; padding: 12px 16px; line-height: 1.6; }
.choice-block input { margin-top: 4px; }

.birth-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.birth-row input { width: 96px; }
.birth-row select { width: 84px; }

.room-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.room-option {
  display: flex !important; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border: 1.5px solid #cbbba3; border-radius: 10px; cursor: pointer; background: #fff;
  font-weight: 400 !important;
}
.room-option:has(input:checked) { border-color: var(--red); background: var(--red-soft); }
.room-option input { width: 20px; height: 20px; accent-color: var(--red); margin-top: 4px; flex: none; }
.room-body { display: flex; flex-direction: column; }
.room-body small { color: var(--muted); font-size: 14px; }

.total-bar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--red); color: #fff; border-radius: var(--radius); padding: 14px 20px; margin-bottom: 16px;
}
.total-bar strong { font-family: var(--serif); font-size: 26px; }
.form-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.form-inline { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; max-width: 760px; }
.form-inline .field { flex: 1 1 200px; margin-bottom: 0; }
.form-inline .btn { min-height: 48px; }
#lookupErr { max-width: 760px; margin: 8px auto 0; }

/* ===== 提示框 ===== */
.alert { border-radius: 10px; padding: 12px 16px; margin: 0 0 16px; border: 1px solid; }
.alert-error { background: var(--err-soft); border-color: #f1b8b4; color: var(--err); }
.alert-error ul { margin: 4px 0 0; padding-left: 20px; }
.alert-warn { background: var(--warn-soft); border-color: #f0d68a; color: var(--warn); max-width: 760px; margin: 0 auto 16px; font-weight: 500; }
.alert-info { background: var(--info-soft); border-color: #cddbe9; color: var(--info); }
.alert-ok { background: var(--ok-soft); border-color: #b9dcbf; color: var(--ok); }

/* ===== 成功畫面 ===== */
.success-panel {
  max-width: 640px; margin: 0 auto; background: #fff; border: 1px solid var(--line);
  border-top: 6px solid var(--ok); border-radius: var(--radius); padding: 28px 24px; text-align: center; box-shadow: var(--shadow);
}
.success-panel:focus { outline: none; }
.success-icon {
  width: 64px; height: 64px; margin: 0 auto 8px; border-radius: 50%;
  background: var(--ok); color: #fff; font-size: 36px; display: grid; place-items: center;
}
.success-panel h3 { font-family: var(--serif); font-size: 24px; margin: 0 0 4px; color: var(--ok); }
.big-code {
  font-family: var(--serif); font-size: 34px; font-weight: 900; letter-spacing: .08em; color: var(--red);
  background: var(--paper); border: 2px dashed var(--gold); border-radius: 10px; padding: 8px; margin: 12px auto 16px; max-width: 320px;
}
.success-panel .form-actions { justify-content: center; }
.summary { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; text-align: left; margin: 0 0 16px; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

/* ===== 查詢結果 ===== */
#lookupResult { max-width: 760px; margin: 16px auto 0; }
.result-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.result-card.is-cancelled { opacity: .7; background: #f7f4f0; }
.result-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.result-head h3 { margin: 0; font-size: 20px; }
.result-code { color: var(--muted); font-size: 14px; }
.empty {
  text-align: center; color: var(--muted); padding: 28px 16px; background: #fff;
  border: 1.5px dashed var(--line); border-radius: var(--radius);
}

.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.badge-paid { background: var(--ok-soft); color: var(--ok); }
.badge-unpaid { background: var(--warn-soft); color: var(--warn); }
.badge-cancel { background: #ece6df; color: var(--muted); }
.badge-demo { background: var(--info-soft); color: var(--info); font-weight: 500; }

/* ===== 管理區 ===== */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.stat p { margin: 0; font-size: 14px; color: var(--muted); }
.stat strong { font-family: var(--serif); font-size: 24px; color: var(--red); }
.admin-tools { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.admin-tools .field { margin-bottom: 0; flex: 1 1 180px; }
.admin-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 15px; min-width: 900px; }
.admin-table th, .admin-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; white-space: nowrap; }
.admin-table thead th { background: var(--gold-soft); position: sticky; top: 0; font-weight: 700; }
.admin-table tr.is-cancelled td { color: var(--muted); text-decoration: line-through; }
.admin-table tr.is-cancelled td:last-child { text-decoration: none; }
.admin-table select { min-height: 36px; padding: 2px 6px; font-size: 14px; width: auto; }
.admin-table .btn-sm { min-height: 34px; padding: 2px 10px; }
.cell-actions { display: flex; gap: 6px; }
.admin-table + .empty, #adminEmpty { margin-top: 12px; }

/* ===== 對話框、Toast ===== */
.dialog {
  border: 0; border-radius: var(--radius); padding: 24px; width: min(420px, calc(100vw - 32px));
  box-shadow: 0 10px 40px rgba(0,0,0,.3); color: var(--ink);
}
.dialog::backdrop { background: rgba(30, 15, 10, .5); }
.dialog h3 { margin: 0 0 8px; font-family: var(--serif); color: var(--red); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: #2a1f1a; color: #fff; padding: 12px 20px; border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25); opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; z-index: 50; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--err); }

/* ===== 頁尾 ===== */
.site-footer { background: #3a2a20; color: #f3e4c8; padding: 24px 0; text-align: center; font-size: 15px; }
.site-footer p { margin: 2px 0; }
.site-footer .muted { color: #c9b89c; font-size: 13px; }

/* ===== 手機 ===== */
@media (max-width: 760px) {
  body { font-size: 16px; }
  .nav-toggle { display: block; }
  .site-nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; background: var(--red-dark); padding: 8px 16px 12px;
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 12px; border-bottom: 1px solid rgba(255,255,255,.1); }
  .br-sm { display: inline; }
  .hero { padding: 36px 0 44px; }
  .hero-date { font-size: 16px; }
  .hero-actions .btn { flex: 1 1 100%; }
  .info-grid, .price-grid, .grid-2, .grid-3, .room-options { grid-template-columns: 1fr; }
  fieldset { padding: 12px 14px 4px; }
  .form-actions .btn { flex: 1 1 100%; }
  .form-inline .btn { flex: 1 1 100%; }
  .section { padding: 40px 0; }
  .section-title { font-size: 24px; }
  .section-title span::before, .section-title span::after { width: 18px; }
  .admin-btns { width: 100%; }
}

/* ===== 狀態、待確認、個資說明 ===== */
.status-pill { display: inline-block; padding: 2px 12px; border-radius: 99px; font-weight: 700; font-size: 15px; background: #efe5d4; color: var(--muted); }
.status-pill.ok { background: var(--ok-soft); color: var(--ok); }
.status-pill.warn { background: var(--warn-soft); color: var(--warn); }
.status-pill.err { background: var(--err-soft); color: var(--err); }
.quota-note { margin-top: 6px; }
.tbd { background: #fff2b3; color: #6b4e00; padding: 0 4px; border-radius: 4px; font-size: .92em; font-weight: 500; }
.tbd::before { content: "【待確認】"; font-size: .85em; }
.center { text-align: center; }
.narrow { max-width: 820px; }
.privacy-list { padding-left: 22px; }
.privacy-list li { margin: 6px 0; }
#lookup > .wrap > .hint { margin-top: 16px; }

/* ===== 後台 ===== */
.admin-body { background: var(--paper); }
.login-card { max-width: 420px; margin: 48px auto; background: #fff; border: 1px solid var(--line); border-top: 6px solid var(--red); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.login-card h1 { font-family: var(--serif); color: var(--red); font-size: 24px; margin: 0 0 4px; }
.login-card input[type="email"], .login-card input[type="password"] {
  width: 100%; min-height: 48px; padding: 8px 12px; font: inherit; border: 1.5px solid #cbbba3; border-radius: 8px;
}
.login-card .btn { width: 100%; margin-top: 8px; }
.login-card .divider { border: 0; border-top: 1px solid var(--line); margin: 20px 0 12px; }
.small { font-size: 14px; }
#forgotMsg { margin-top: 12px; }
.admin-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 24px 0 16px; }
.admin-top h1 { font-family: var(--serif); color: var(--red); margin: 0; font-size: 26px; }
.admin-user { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 15px; color: var(--muted); }
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 20px; box-shadow: var(--shadow); }
.panel h2 { font-family: var(--serif); color: var(--red); font-size: 20px; margin: 0 0 12px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 16px; align-items: end; }
.settings-grid input[type="datetime-local"] { width: 100%; min-height: 48px; padding: 8px 12px; font: inherit; border: 1.5px solid #cbbba3; border-radius: 8px; }
.flag { color: var(--warn); font-size: 13px; font-weight: 700; }
.log-list { list-style: none; margin: 0; padding: 0; font-size: 14px; max-height: 320px; overflow: auto; }
.log-list li { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.log-list time { color: var(--muted); margin-right: 8px; }
.detail-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 12px; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }
.dialog textarea { width: 100%; min-height: 70px; font: inherit; padding: 8px; border: 1.5px solid #cbbba3; border-radius: 8px; }
.dialog-wide { width: min(560px, calc(100vw - 32px)); }
@media (max-width: 760px) {
  .site-nav.site-nav-static { display: flex; position: static; flex-direction: row; background: transparent; padding: 0; }
  .site-nav.site-nav-static a { border: 0; padding: 8px 10px; }
}

/* ===== 列印確認單 ===== */
@media print {
  .demo-banner, .site-header, .hero, #info, #lookup, #privacy, #admin, .site-footer, #regForm, .success-panel .form-actions, .toast { display: none !important; }
  .section-paper { background: #fff; border: 0; }
  #register .section-title, #register .section-lead { display: none; }
  .success-panel { box-shadow: none; border: 1px solid #999; }
}
