/* 管理頁面 */
:root { --ink: #16201C; --muted: #4E5A55; --line: #D9DDD8; --bg: #EEF0EC; --board: #0F2A22; --amber: #F2B33D; --teal: #0F766E; }
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Noto Sans TC', system-ui, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--teal); }
.mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; }
.muted { color: var(--muted); }

.topbar { background: var(--board); color: #F3F1E7; display: flex; align-items: center; gap: 20px; padding: 10px 24px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: #F3F1E7; text-decoration: none; font-weight: 700; font-size: 17px; }
.brand-mark { width: 34px; height: 34px; display: inline-block; flex: none; }
.brand-mark.big { width: 64px; height: 64px; }
.topnav { display: flex; gap: 6px; flex: 1; }
.topnav a { color: #C9D6CF; text-decoration: none; padding: 8px 12px; border-radius: 8px; }
.topnav a:hover { background: #163A2F; color: #fff; }
.logout { display: flex; align-items: center; gap: 10px; margin: 0; }
.who { font-size: 13px; color: #9FB8AB; }

.page { max-width: 1650px; margin: 0 auto; padding: 20px 24px 40px; }   /* 寬螢幕（1920）加寬 50%：原 1100px */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: 24px; }
.flash { background: #E3EFEA; color: #0B5A54; border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-weight: 700; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.empty { text-align: center; color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid #C5CCC6; background: #fff; color: var(--ink); font: inherit; font-size: 14px; font-weight: 700; text-decoration: none; cursor: pointer; }
.btn-primary { background: var(--amber); border-color: var(--amber); color: var(--board); }
.btn-dark { background: var(--board); border-color: var(--board); color: #fff; }
.btn-ghost { background: transparent; color: #F3F1E7; border-color: #3C5A4E; min-height: 36px; }
.block { width: 100%; }

.game-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.game { display: flex; flex-direction: column; gap: 12px; }
.game.live { border: 2px solid var(--amber); }
.game-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); gap: 8px; }
.badge { padding: 2px 10px; border-radius: 999px; font-weight: 700; background: var(--bg); }
.status-live { background: #FDF3E1; color: #8A4B08; }
.status-final { background: #E3EFEA; color: #0B5A54; }
.game-score { display: flex; align-items: center; justify-content: space-between; }
.team { text-align: center; flex: 1; display: flex; flex-direction: column; }
.team small { color: var(--muted); }
.team b { font-size: 18px; }
.score { font-size: 32px; font-weight: 700; }
/* 比賽卡片的按鈕：各狀態一致的等寬格狀排列，主要按鈕（記錄／查看）佔滿一列 */
.game-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.game-actions .btn { width: 100%; justify-content: center; text-align: center; }
.game-actions .btn-dark { grid-column: 1 / -1; }
.game-inning { text-align: center; font-weight: 700; font-size: 14px; color: var(--muted); margin-top: -6px; }
.game.live .game-inning { color: #B42318; }

.form { display: flex; flex-direction: column; gap: 14px; }
.sec { font-size: 14px; color: var(--board); margin: 8px 0 0; letter-spacing: .06em; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.wide { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 700; color: var(--muted); }
.input { min-height: 44px; border-radius: 10px; border: 1px solid #C5CCC6; background: #fff; padding: 0 12px; font: inherit; font-size: 15px; width: 100%; }
.check { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 14px; }
.check input { width: 20px; height: 20px; }
.err, .field-validation-error { color: #B42318; font-size: 13px; }
.errors ul { margin: 0; padding-left: 18px; color: #B42318; }
.validation-summary-valid { display: none; }
.input-validation-error { border-color: #B42318; }
.hint { font-size: 12px; color: var(--muted); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

.lineup { display: flex; flex-direction: column; gap: 8px; }
.lineup-head, .lineup-row { display: grid; grid-template-columns: 48px minmax(0, 2fr) minmax(0, 1fr); gap: 8px; align-items: center; }
.lineup-head { font-size: 12px; font-weight: 700; color: var(--muted); }
.order { font-size: 18px; font-weight: 700; text-align: center; }

.login { max-width: 420px; margin: 40px auto; display: flex; flex-direction: column; gap: 16px; }
.login-head { text-align: center; }
.login-head h1 { margin: 10px 0 4px; }
.login-head p { margin: 0; color: var(--muted); }

/* 匯入手機備份 */
.warn-box { background: #FDF3E1; color: #8A4B08; font-weight: 700; margin-bottom: 14px; }
.errors.card:empty, .errors.card.validation-summary-valid { display: none; }
.errors.card { margin-bottom: 14px; }
.compare-summary { display: flex; gap: 24px; flex-wrap: wrap; }
.compare-summary small { display: block; color: var(--muted); font-size: 12px; }
.compare-summary b { font-size: 26px; }
.compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.compare h3, .option h3 { font-size: 15px; margin: 0 0 8px; }
.compare > div { border: 1px solid var(--line); border-radius: 12px; padding: 12px; max-height: 420px; overflow-y: auto; }
.log-line { display: grid; grid-template-columns: 40px 1fr auto; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--bg); font-size: 13px; }
.log-line:last-child { border-bottom: none; }
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.option { border: 2px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.option p { margin: 0; font-size: 14px; }
.option.disabled { opacity: .6; }
.option .result b { font-size: 18px; }

/* 結束比賽 */
.endgame { display: flex; flex-direction: column; gap: 14px; max-width: 760px; margin: 0 auto; }
.score-card { display: flex; align-items: center; justify-content: space-around; text-align: center; }
.score-card small { display: block; color: var(--muted); font-size: 13px; }
.score-card b { font-size: 20px; }
.score-card .final { font-size: 40px; font-weight: 700; }
.sub-h { font-size: 14px; margin: 10px 0 2px; }
.opts { display: flex; flex-direction: column; gap: 6px; }
.opt { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 12px; border: 1px solid #C5CCC6; border-radius: 12px; cursor: pointer; background: #fff; }
.opt:has(input:checked) { border: 2px solid #B45309; background: #FDF3E1; }
.opt input { width: 20px; height: 20px; accent-color: #B45309; flex: none; }
.opt-body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.opt-body small { color: var(--muted); font-size: 13px; }
.tag { flex: none; font-size: 12px; font-weight: 700; color: #0B5A54; background: #E3EFEA; border-radius: 999px; padding: 2px 8px; }
.more summary { cursor: pointer; color: var(--teal); font-weight: 700; padding: 6px 0; }
.end-actions { position: sticky; bottom: 0; display: flex; gap: 8px; padding: 12px 0; background: var(--bg); }
.end-actions .btn { flex: 1; min-height: 52px; }
.end-actions .btn-primary { flex: 2; }

/* 聯盟切換、導覽 */
.league-switch select { min-height: 36px; border-radius: 8px; border: 1px solid #3C5A4E; background: #163A2F; color: #F3F1E7; font: inherit; font-size: 14px; font-weight: 700; padding: 0 8px; }
.league-name { color: #F2B33D; font-weight: 700; font-size: 14px; }
.topnav a.on { background: #163A2F; color: #fff; }
.topnav { flex-wrap: wrap; }

/* 通用：表格、標籤、兩欄 */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 8px; border-bottom: 1px solid var(--bg); vertical-align: middle; }
.tbl tr.sel td { background: #FDF3E1; }
.tbl tr.click { cursor: pointer; }
.tbl .num { text-align: center; font-family: 'IBM Plex Mono', monospace; }
.tbl-wrap { overflow-x: auto; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--bg); }
.pill.ACTIVE { background: #E3EFEA; color: #0B5A54; }
.pill.INJURED { background: #FDF3E1; color: #8A4B08; }
.pill.LEFT { background: #EEF0EC; color: #4E5A55; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid #C5CCC6; background: #fff; color: var(--ink); font-size: 14px; font-weight: 700; text-decoration: none; }
.chip.on { background: var(--board); border-color: var(--board); color: #fff; }
.split { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.side-list { display: flex; flex-direction: column; gap: 4px; padding: 8px; }
.side-item { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; color: var(--ink); text-decoration: none; }
.side-item.on { background: #FDF3E1; }
.side-item small { display: block; color: var(--muted); font-size: 12px; }
.badge-team { width: 34px; height: 34px; border-radius: 8px; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 900; flex: none; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.panel-head h2 { margin: 0; font-size: 18px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 700; }
.section-gap { display: flex; flex-direction: column; gap: 16px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { min-width: 140px; }

/* 使用者與權限 */
.users-split { grid-template-columns: minmax(0, 1fr) 340px; }
@media (max-width: 1000px) { .users-split { grid-template-columns: 1fr; } }
.pill.r-admin { background: #26312C; color: #fff; }
.pill.r-league { background: #F2B33D; color: #0F2A22; }
.pill.r-scorer { background: #E3EFEA; color: #0B5A54; }
.pill.r-team { background: #DCE6FF; color: #1E3A8A; }
.link-box { margin-bottom: 14px; display: flex; flex-direction: column; gap: 8px; }
.link-row { display: flex; gap: 8px; flex-wrap: wrap; }
.link-row .input { flex: 1; min-width: 240px; font-size: 13px; }
.assign-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--bg); }
.perm td.yes { color: #0B5A54; font-weight: 700; }
.perm td.part { color: #8A4B08; font-weight: 700; }
.perm td.no { color: #9AA39F; }
.who-link { color: #C9D6CF; text-decoration: none; font-size: 13px; }
.who-link small { color: #F2B33D; margin-left: 4px; }

/* 圖片上傳、Logo */
.image-upload { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.image-preview { width: 96px; height: 96px; border-radius: 12px; border: 1px dashed #C5CCC6; display: flex; align-items: center; justify-content: center; background: #fff; overflow: hidden; flex: none; }
.image-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.image-preview .muted { font-size: 12px; }
.image-actions { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 240px; }
.image-actions .inline-form .input { flex: 1; min-width: 180px; }
.badge-logo { width: 34px; height: 34px; border-radius: 8px; object-fit: contain; background: #fff; border: 1px solid var(--line); flex: none; }
.league-logo { width: 28px; height: 28px; border-radius: 6px; object-fit: contain; background: #fff; }

/* 必填欄位：標籤後加紅色 * */
.required::after { content: " *"; color: #D32F2F; font-weight: 900; }

/* 本場可上場名單 */
.squad { border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.squad-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; }
.squad-item { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 10px; border: 1px solid #C5CCC6; border-radius: 10px; background: #fff; cursor: pointer; }
.squad-item:has(input:checked) { border-color: #0F766E; background: #E3EFEA; }
.squad-item.locked { cursor: default; border-color: #0F766E; background: #E3EFEA; }
.squad-item input { width: 18px; height: 18px; accent-color: #0F766E; flex: none; }
.squad-item .no { width: 36px; font-weight: 700; }
.squad-item .nm { flex: 1; display: flex; flex-direction: column; font-weight: 700; }
.squad-item small { font-weight: 400; color: var(--muted); font-size: 12px; }

/* 權限設定 */
.pill.r-record { background: #FDE7C8; color: #8A4B08; }
.pill.r-custom { background: #EDE3F5; color: #6B2F8F; }
.perm-sum { font-size: 13px; color: var(--muted); max-width: 280px; }
.perm-list { display: flex; flex-direction: column; gap: 4px; }
.perm-item { display: flex; gap: 8px; align-items: flex-start; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.perm-item:has(input:checked) { background: #E3EFEA; }
.perm-item input { width: 18px; height: 18px; margin-top: 2px; accent-color: #0F766E; flex: none; }
.perm-item span { display: flex; flex-direction: column; }
.perm-item small { color: var(--muted); font-size: 12px; }
.perm-teams { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 8px 6px 34px; }
.chip-check { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 10px; border: 1px solid #C5CCC6; border-radius: 10px; background: #fff; font-size: 14px; font-weight: 700; cursor: pointer; }
.chip-check:has(input:checked) { border-color: #0F766E; background: #E3EFEA; }
.chip-check input { accent-color: #0F766E; }
button.chip { cursor: pointer; }
.assigned-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 10px; border-radius: 999px; background: #E3EFEA; color: #0B5A54; font-size: 13px; font-weight: 700; }
.assigned-chip button { border: 0; background: transparent; color: #0B5A54; font-size: 16px; cursor: pointer; padding: 0 6px; }
.squad-item.suspended { background: #FBEAEA; border-color: #E2A6A6; cursor: not-allowed; }
.squad-item.suspended small { color: #B42318; }
.pill.SUSPENDED { background: #FBEAEA; color: #B42318; }

/* 數據分析 */
.ana-grid { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .ana-grid { grid-template-columns: 1fr; } }
.spray { width: 100%; height: auto; display: block; }
.spray-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; margin-top: 6px; }
.spray-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
.dot.hit { background: #D32F2F; } .dot.out { background: #fff; border: 1.6px solid #26312C; } .dot.err { background: #7B3FA0; }
.stat-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat-cards div { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.stat-cards small { display: block; color: var(--muted); font-size: 12px; }
.stat-cards b { font-family: 'IBM Plex Mono', monospace; font-size: 22px; }
.bar-row { display: flex; height: 30px; border-radius: 8px; overflow: hidden; margin-bottom: 8px; }
.bar { display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; }
.bar.gb { background: #8A6D3B; } .bar.ld { background: #D32F2F; } .bar.fb { background: #1D4ED8; } .bar.pu { background: #6B7570; }
.bar.pull { background: #0F766E; } .bar.center { background: #6B7570; } .bar.oppo { background: #B45309; }
.tbl .nw { white-space: nowrap; }
/* 生涯成績 */
.tbl tr.total td { background: #F4F2EC; font-weight: 700; }
.trend { width: 100%; height: auto; display: block; }
@media (max-width: 700px) { .stat-cards { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; } }

/* 導覽下拉選單（同類型功能放在一起） */
.navmenu { position: relative; }
.navmenu > summary { list-style: none; cursor: pointer; color: #C9D6CF; padding: 8px 12px; border-radius: 8px; user-select: none; }
.navmenu > summary::-webkit-details-marker { display: none; }
.navmenu > summary::after { content: "▾"; margin-left: 4px; font-size: 11px; opacity: .8; }
.navmenu > summary:hover, .navmenu[open] > summary, .navmenu.on > summary { background: #163A2F; color: #fff; }
.navmenu-list { position: absolute; top: calc(100% + 4px); left: 0; z-index: 40; min-width: 180px; background: #fff; border-radius: 12px;
    box-shadow: 0 10px 30px rgba(15, 42, 34, .22); padding: 6px; display: flex; flex-direction: column; }
.topnav .navmenu-list a { color: var(--ink); padding: 9px 12px; border-radius: 8px; white-space: nowrap; }
.topnav .navmenu-list a:hover { background: #E3EFEA; color: var(--ink); }
.topnav .navmenu-list a.on { background: #E3EFEA; color: #0B5A54; font-weight: 700; }
/* 方案 */
.usage { height: 10px; border-radius: 999px; background: #E3E7E4; overflow: hidden; margin-top: 6px; }
.usage > div { height: 100%; background: #0F766E; }
.usage > div.warn { background: #B45309; }
.usage > div.full { background: #B42318; }
