/* 高雄全家海神 主場賽事門票 索票系統
   風格取自主視覺：深海藍夜景、金色光芒、白色斜切卡片 */
:root {
  --navy-900: #020a22;
  --navy-800: #061a45;
  --navy-700: #0b2a6b;
  --blue-500: #1f63c9;
  --gold-300: #ffe08a;
  --gold-500: #f4b52a;
  --gold-700: #c27a10;
  --gold-grad: linear-gradient(180deg, #fff1b8 0%, #f6c445 45%, #d08a12 100%);
  --ink: #0b1a3a;
  --muted: #5a6784;
  --line: #d9e0ee;
  --card: #ffffff;
  --ok: #1aa260;
  --warn: #e08a00;
  --danger: #d64235;
  --font: "Noto Sans TC", system-ui, -apple-system, "Microsoft JhengHei", sans-serif;
  --num: "Oswald", "Noto Sans TC", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
html { background: var(--navy-900); }
body {
  font-family: var(--font); color: var(--ink); line-height: 1.6; -webkit-text-size-adjust: 100%;
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(31, 99, 201, .55), transparent 60%),
    radial-gradient(900px 400px at 0% 30%, rgba(244, 181, 42, .12), transparent 60%),
    linear-gradient(180deg, var(--navy-800) 0%, var(--navy-900) 70%);
  min-height: 100vh;
}
button, input, select { font: inherit; }
.hidden { display: none !important; }

/* ---------- 主視覺 ---------- */
.kv { max-width: 960px; margin: 0 auto; position: relative; }
.kv img { display: block; width: 100%; height: auto; }
.kv::after { content: ""; position: absolute; inset: auto 0 0 0; height: 14%; background: linear-gradient(180deg, transparent, var(--navy-800)); pointer-events: none; }
.kv h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

main { max-width: 960px; margin: 16px auto 48px; padding: 0 16px; position: relative; z-index: 1; }

/* ---------- 卡片：白底、金框、斜切角（呼應主視覺 01/02/03 面板） ---------- */
.card {
  background: var(--card);
  border: 2px solid var(--gold-500);
  border-radius: 4px 22px 4px 22px;
  padding: 22px 20px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 0 4px rgba(6, 26, 69, .9), 0 12px 32px rgba(0, 0, 0, .45);
}
.card-title {
  display: inline-flex; align-items: center; gap: 10px;
  margin: -22px 0 16px -20px; padding: 10px 26px 10px 20px;
  background: linear-gradient(90deg, var(--navy-700), var(--blue-500));
  color: #fff; font-size: 19px; font-weight: 900; letter-spacing: .06em; font-style: italic;
  clip-path: polygon(0 0, 100% 0, calc(100% - 16px) 100%, 0 100%);
}
.card-title .no { font-family: var(--num); color: var(--gold-300); font-size: 20px; }

.status {
  display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap;
  padding: 12px 16px; border-radius: 4px; font-weight: 700; text-align: center;
  background: linear-gradient(90deg, rgba(244, 181, 42, .14), rgba(244, 181, 42, .28), rgba(244, 181, 42, .14));
  color: #fff; border: 1px solid rgba(244, 181, 42, .6);
}
.status.not_open { color: var(--gold-300); }
.status.err { background: rgba(214, 66, 53, .2); border-color: var(--danger); }

/* ---------- 表單 ---------- */
label { display: block; font-size: 14px; color: var(--muted); margin: 0 0 6px; font-weight: 500; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], input[type=datetime-local], select {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 4px; background: #f7f9fd; font-size: 16px; color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--gold-500); outline-offset: 1px; background: #fff; }
.field { margin-bottom: 14px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 22px; border: 0; border-radius: 4px; cursor: pointer; font-weight: 900; letter-spacing: .08em; white-space: nowrap;
  background: linear-gradient(180deg, var(--blue-500), var(--navy-700)); color: #fff;
}
.btn:hover { filter: brightness(1.12); }
.btn:disabled { opacity: .4; cursor: not-allowed; filter: grayscale(.4); }
.btn.gold { background: var(--gold-grad); color: var(--navy-900); text-shadow: 0 1px 0 rgba(255, 255, 255, .5); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15); }
.btn.ghost { background: transparent; color: var(--navy-700); border: 1px solid var(--line); letter-spacing: 0; font-weight: 700; }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid #f0c2bd; letter-spacing: 0; font-weight: 700; }
.btn.sm { padding: 7px 14px; font-size: 14px; }
.btn.block { width: 100%; }

/* ---------- 使用者 ---------- */
.user-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.user-bar .who b { font-size: 20px; }
.pill { display: inline-block; border-radius: 999px; padding: 3px 12px; font-size: 13px; font-weight: 700; background: var(--navy-700); color: #fff; }
.pill.gold { background: var(--gold-grad); color: var(--navy-900); }
.pill.grey { background: #e7ebf3; color: var(--muted); }

/* ---------- 場次 ---------- */
.batch { margin-bottom: 22px; }
.batch-head { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline; padding: 0 0 8px; border-bottom: 2px solid var(--gold-500); margin-bottom: 12px; }
.batch-head b { font-size: 15px; color: var(--navy-700); }
.batch-head span { font-size: 13px; color: var(--muted); }
.batch-head span.pill { color: #fff; }
.batch-head span.pill.grey { color: var(--muted); }
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.game {
  border: 1px solid var(--line); border-radius: 4px; padding: 14px; background: linear-gradient(180deg, #fff, #f4f7fc);
  display: flex; flex-direction: column; gap: 8px; position: relative; overflow: hidden;
}
.game::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--blue-500); }
.game.mine { border-color: var(--gold-500); box-shadow: 0 0 0 2px rgba(244, 181, 42, .45); }
.game.mine::before { background: var(--gold-500); }
.game.closed, .game.full { opacity: .55; }
.game .date { display: flex; align-items: baseline; gap: 8px; }
.game .date b { font-family: var(--num); font-size: 26px; font-weight: 700; color: var(--navy-800); line-height: 1; }
.game .date span { color: var(--muted); font-size: 14px; }
.game .vs { font-weight: 900; font-size: 17px; }
.game .vs small { color: var(--gold-700); font-family: var(--num); font-size: 15px; margin-right: 4px; }
.game .meta { font-size: 13px; color: var(--muted); }
.bar { height: 8px; background: #e2e8f2; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue-500), #4fa3ff); }
.bar.low > i { background: linear-gradient(90deg, var(--gold-700), var(--gold-500)); }
.bar.none > i { background: var(--danger); }
.remain { font-size: 14px; }
.remain b { font-family: var(--num); font-size: 22px; color: var(--navy-800); }
.game .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.game select { width: auto; padding: 7px 10px; font-size: 15px; }

.my-list { list-style: none; padding: 0; margin: 0; }
.my-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--line); flex-wrap: wrap; }
.my-list li:last-child { border-bottom: 0; }
.empty { color: var(--muted); text-align: center; padding: 18px 0; }

.rules { margin: 0; padding-left: 20px; color: var(--muted); font-size: 14px; }
.rules li { margin: 4px 0; }

/* ---------- 對話框、提示 ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(2, 10, 34, .7); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: #fff; max-width: 420px; width: 100%; padding: 22px 20px; border: 2px solid var(--gold-500); border-radius: 4px 18px 4px 18px; }
.modal h3 { margin: 0 0 14px; font-style: italic; font-weight: 900; }
.modal dl { display: grid; grid-template-columns: 80px 1fr; gap: 6px 10px; margin: 0 0 18px; }
.modal dt { color: var(--muted); }
.modal dd { margin: 0; font-weight: 700; }
.modal .row { display: flex; gap: 10px; }
.modal .row .btn { flex: 1; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--navy-800); color: #fff; padding: 12px 18px; border-radius: 4px; z-index: 60; max-width: calc(100% - 32px); box-shadow: 0 0 0 1px var(--gold-500); }
.toast.err { background: var(--danger); box-shadow: none; }

footer { text-align: center; color: rgba(255, 255, 255, .55); font-size: 13px; padding: 0 16px 32px; }

/* ---------- 後台 ---------- */
.admin-head { max-width: 960px; margin: 0 auto; padding: 28px 16px 52px; color: #fff; }
.admin-head h1 { margin: 0; font-style: italic; font-weight: 900; letter-spacing: .06em; background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; white-space: nowrap; }
td input[type=text], td input[type=number], td input[type=date], td input[type=time], td input[type=datetime-local] { padding: 6px 8px; font-size: 14px; }
.table-wrap { overflow-x: auto; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs button { background: rgba(255, 255, 255, .08); color: #fff; border: 1px solid rgba(255, 255, 255, .25); border-radius: 999px; padding: 8px 16px; cursor: pointer; }
.tabs button.on { background: var(--gold-grad); color: var(--navy-900); border-color: transparent; font-weight: 700; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.stat { background: #f2f5fb; border-radius: 4px; padding: 12px; border-left: 4px solid var(--gold-500); }
.stat b { display: block; font-family: var(--num); font-size: 26px; color: var(--navy-800); }

/* ---------- 後台：場次管理 ---------- */
.sb-toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 10px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { background: #fff; border: 0; padding: 7px 14px; cursor: pointer; font-size: 14px; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--navy-700); color: #fff; }
.seg button i { font-style: normal; font-family: var(--num); opacity: .8; margin-left: 2px; }
.sb-batch { border: 1px solid var(--line); border-radius: 6px; margin-bottom: 16px; overflow: hidden; }
.sb-head { display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: center; padding: 10px 14px; background: linear-gradient(90deg, #eef3fb, #f8fafd); border-bottom: 2px solid var(--gold-500); }
.sb-head b { color: var(--navy-800); }
.sb-label { display: block; font-size: 12px; color: var(--muted); }
.sb-game { display: grid; grid-template-columns: 130px 1fr 190px 92px auto; gap: 14px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); }
.sb-head + .sb-game { border-top: 0; }
.sb-game.off { background: #f6f7f9; }
.sb-game.off .sb-date, .sb-game.off .sb-vs, .sb-game.off .sb-qty { opacity: .5; }
.sb-date b { display: block; font-family: var(--num); font-size: 20px; color: var(--navy-800); line-height: 1.2; }
.sb-date span { font-size: 13px; color: var(--muted); }
.sb-vs { font-weight: 700; }
.sb-vs small { color: var(--gold-700); font-family: var(--num); margin-right: 4px; }
.sb-vs .hint { font-weight: 400; margin: 0; }
.sb-qty span { font-size: 13px; color: var(--muted); }
.sb-qty b { font-family: var(--num); font-size: 16px; color: var(--navy-800); }
.sb-qty .bar { margin-bottom: 4px; }
.sb-act { display: flex; gap: 6px; justify-content: flex-end; }
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; margin: 0; color: var(--ink); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span { width: 38px; height: 22px; border-radius: 99px; background: #c9d1de; position: relative; transition: background .15s; flex: none; }
.switch span::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 rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--gold-500); outline-offset: 2px; }
.switch em { font-style: normal; font-size: 13px; }
.modal.wide { max-width: 560px; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 12px; }
.form-grid input { min-width: 0; }
.form-grid .span2 { grid-column: span 2; }
.modal form, form.modal { max-height: calc(100vh - 32px); overflow-y: auto; }
@media (max-width: 720px) {
  .sb-game { grid-template-columns: 1fr auto; gap: 8px 12px; }
  .sb-date { grid-column: 1; } .switch { grid-column: 2; grid-row: 1; justify-self: end; }
  .sb-vs, .sb-qty { grid-column: span 2; }
  .sb-act { grid-column: span 2; justify-content: flex-start; }
  .form-grid { grid-template-columns: 1fr; } .form-grid .span2 { grid-column: auto; }
}

/* 後台：篩選列 */
.filter-bar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 1.2fr); gap: 8px; margin-bottom: 8px; }
.filter-bar select, .filter-bar input { padding: 9px 10px; font-size: 14px; }
@media (max-width: 720px) { .filter-bar { grid-template-columns: 1fr 1fr; } .filter-bar input { grid-column: span 2; } }

/* 個資遮蔽輸入框 */
.secret { position: relative; }
.secret input { padding-right: 64px; letter-spacing: .08em; }
.secret .eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--muted); padding: 6px 8px; cursor: pointer; border-radius: 4px; display: flex; align-items: center; }
.secret .eye.on { color: var(--navy-700); }
.secret .eye:hover { background: #eaf0f9; }

/* 後台：同仁搜尋結果 */
.pick-list { border: 1px solid var(--line); border-top: 0; border-radius: 0 0 4px 4px; max-height: 240px; overflow-y: auto; }
.pick-list:empty { display: none; }
.pick-list button { display: block; width: 100%; text-align: left; background: #fff; border: 0; border-top: 1px solid var(--line); padding: 8px 12px; cursor: pointer; font-size: 14px; }
.pick-list button:hover { background: #eef3fb; }
.pick-list button span { display: block; font-size: 12px; color: var(--muted); }

/* ---------- 後台：人事清單 ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chips button { display: flex; align-items: baseline; gap: 6px; background: #f2f5fb; border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; cursor: pointer; font-size: 14px; color: var(--muted); }
.chips button b { font-family: var(--num); font-size: 20px; color: var(--navy-800); }
.chips button.warn b { color: var(--danger); }
.chips button.on { background: var(--navy-700); border-color: var(--navy-700); color: #fff; }
.chips button.on b { color: var(--gold-300); }
.list-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin: 6px 0; }
.pager { display: inline-flex; align-items: center; gap: 8px; }
.pager button { background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 4px 10px; cursor: pointer; font-size: 13px; }
.pager button:disabled { opacity: .4; cursor: default; }
.staff-table { max-height: 70vh; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.staff-table thead th { position: sticky; top: 0; background: #f2f5fb; z-index: 1; }
.staff-table td { padding: 9px 10px; }
.staff-table th { padding: 9px 10px; }
.staff-table .sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.staff-table .num { text-align: right; white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; white-space: nowrap; }
.person-row { cursor: pointer; }
.person-row:hover { background: #f5f8fd; }
.group-row td { background: #e9eef8; font-weight: 700; color: var(--navy-800); font-size: 13px; padding: 6px 10px; }
.group-row span { margin-left: 10px; font-weight: 500; color: var(--muted); }
.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; margin-right: 4px; white-space: nowrap; }
.tag.ok { background: #e3f5ec; color: var(--ok); }
.tag.warn { background: #fdecea; color: var(--danger); }
.tag.off { background: #eceff3; color: var(--muted); }
.import-box { margin-top: 22px; border: 1px dashed var(--line); border-radius: 6px; padding: 10px 14px; }
.import-box summary { cursor: pointer; font-weight: 700; color: var(--navy-700); }
.import-box[open] summary { margin-bottom: 8px; }

/* 個人詳細資料側邊面板 */
.drawer-bg { justify-content: flex-end; align-items: stretch; padding: 0; }
.drawer { background: #fff; width: min(420px, 100%); height: 100%; overflow-y: auto; padding: 20px; border-left: 3px solid var(--gold-500); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.drawer-head h3 { margin: 0; font-size: 22px; }
.pd-info { display: grid; grid-template-columns: 70px 1fr; gap: 8px 10px; margin: 0 0 16px; font-size: 15px; }
.pd-info dt { color: var(--muted); }
.pd-info dd { margin: 0; }
.pd-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.drawer h4 { margin: 16px 0 8px; }
.pd-tickets { list-style: none; padding: 0; margin: 0; }
.pd-tickets li { padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px; display: flex; justify-content: space-between; gap: 8px; }
.pd-tickets li span { color: var(--muted); white-space: nowrap; }

/* 小眼睛（後台個資顯示切換） */
.eye-btn { border: 0; background: transparent; color: var(--muted); padding: 4px; margin: -4px 0; cursor: pointer; border-radius: 4px; display: inline-flex; align-items: center; vertical-align: middle; flex: none; }
.eye-btn:hover { background: #eaf0f9; color: var(--navy-700); }
.eye-btn.on { color: var(--navy-700); }
.pii-wrap { display: flex; align-items: center; gap: 8px; }
.pii .mono { min-width: 92px; letter-spacing: .02em; }
.pii-miss { color: var(--danger); font-size: 12px; }
.pii-th { white-space: nowrap; }
.pii-th .eye-btn { margin-left: 4px; }

.bad-ids { margin-top: 8px; color: var(--ink); }
.bad-ids summary { cursor: pointer; color: var(--danger); font-weight: 700; }
.bad-ids ul { margin: 6px 0 0; padding-left: 20px; max-height: 200px; overflow: auto; font-size: 13px; }
