/* =====================================================================
   極簡表格風 (Minimal) — 載入於 style.css 之後。
   還原舊風格：從 index.html 移除 <link rel="stylesheet" href="/minimal.css"> 即可。
   夜間 = 亮色重點的深色 (dark-bright)；日間 = 白底。
   ===================================================================== */

:root {
    --font-ui: system-ui, -apple-system, "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
    --bg-dark: #14161a;
    --nav-bg: #14161a;
    --panel-bg: transparent;
    --card-sub-bg: rgba(255, 255, 255, 0.03);
    --card-hover-bg: rgba(255, 255, 255, 0.05);
    --input-bg: #14161a;
    --readonly-bg: #1b1f25;
    --border-subtle: #232830;
    --border-mid: #343944;
    --gold-primary: #5fb0ff;
    --gold-light: #ffffff;
    --gold-dark: #343944;
    --accent-cyan: #5fb0ff;
    --k1-blue: #5fb0ff;
    --k2-red: #ff6b6b;
    --text-main: #ffffff;
    --text-muted: #b8bcc6;
    --text-soft: #d6d9e0;
    --tab-header-bg: transparent;
    --tab-row-odd: transparent;
    --tab-row-even: transparent;
    --drawer-bg: #1b1f25;
    --onaccent: #0b1220;
    --warn: #ffc247;
    --red: #ff6b6b;
}
body.light-mode {
    --bg-dark: #ffffff;
    --nav-bg: #ffffff;
    --panel-bg: transparent;
    --card-sub-bg: #f4f5f7;
    --card-hover-bg: #f4f5f7;
    --input-bg: #ffffff;
    --readonly-bg: #f4f5f7;
    --border-subtle: #eceef2;
    --border-mid: #dfe2e8;
    --gold-primary: #2563eb;
    --gold-light: #14161a;
    --gold-dark: #dfe2e8;
    --accent-cyan: #2563eb;
    --k1-blue: #2563eb;
    --k2-red: #d32f2f;
    --text-main: #14161a;
    --text-muted: #5d6470;
    --text-soft: #3c424d;
    --tab-header-bg: transparent;
    --tab-row-odd: transparent;
    --tab-row-even: transparent;
    --drawer-bg: #f4f5f7;
    --onaccent: #ffffff;
    --warn: #b45309;
    --red: #d32f2f;
    background-image: none !important;
}

/* ---------- 基礎：平面、無光暈、無漸層、系統字體 ---------- */
body { font-family: var(--font-ui); background-image: none !important; background-color: var(--bg-dark); }
*, *::before, *::after { box-shadow: none !important; text-shadow: none !important; }
h1, h2, h3, h4, .brand-text h2, .mp-hero-section h1, .header-banner h1, .panel-title, .btn-battle,
.vs-badge, .k1-panel h2, .k2-panel h2, [style*="Cinzel"], [style*="Rajdhani"] { font-family: var(--font-ui) !important; letter-spacing: 0 !important; }
.view-section { font-variant-numeric: tabular-nums; }
.tabulator, .mp-board-row, .mp-kpi-card, .data-table, .pcard, .hx-card, .drawer-card, .profile-stat-box { font-variant-numeric: tabular-nums; }

/* ---------- 導覽列：純文字，目前頁面以底線標示 ---------- */
.top-navbar { backdrop-filter: none; -webkit-backdrop-filter: none; border-bottom: 1px solid var(--border-mid); height: auto; min-height: 56px; }
.brand-icon-wrap { display: none; }
.brand-text h2 { font-size: 15px; font-weight: 700; letter-spacing: 0; }
.brand-text span { display: none; }
.top-nav-links li a { border-radius: 0; border: 0; border-bottom: 2px solid transparent; padding: 18px 4px; margin: 0 8px; font-weight: 500; font-size: 14px; background: none; }
.top-nav-links li a:hover { color: var(--text-main); background: none; }
.top-nav-links li a.active { color: var(--text-main); background: none; border-bottom-color: var(--gold-primary); font-weight: 700; }
.top-nav-links li a i { display: none; }
.btn-nav-tool, .nav-auth-pill { background: none; border: 0; color: var(--text-muted); border-radius: 4px; font-weight: 500; }
.btn-nav-tool:hover { color: var(--text-main); background: var(--card-sub-bg); }

/* ---------- 區塊：不用卡片，只用細線 ---------- */
.panel-card { background: transparent; border: 0; border-top: 1px solid var(--border-mid); border-radius: 0; padding: 24px 0; margin-bottom: 8px; }
.panel-title { font-size: 16px; font-weight: 600; color: var(--text-main); border-bottom: 0; padding-bottom: 8px; }
.panel-title i { display: none; }
.header-banner { background: none; border: 0; padding: 8px 0 16px; }
.header-banner h1 { font-size: 24px; font-weight: 600; color: var(--text-main); }
.header-banner h1 i { display: none; }
.header-banner p { color: var(--text-muted); }
.hint-badge, .toolbar-label { color: var(--text-muted); font-weight: 500; }

/* ---------- 首頁 Hero / 搜尋 ---------- */
.mp-hero-section { background: none; border: 0; border-radius: 0; text-align: left; padding: 24px 0 8px; margin-bottom: 8px; }
.mp-hero-section h1 { font-size: 28px; font-weight: 600; color: var(--text-main); }
.mp-hero-section p { color: var(--text-muted); font-size: 14px; text-align: left; margin-left: 0; margin-right: 0; max-width: none; }
.mp-pulse-badge { display: none; }
.mp-search-omnibox { margin: 16px 0 0; width: 100%; max-width: none; min-height: 56px; border: 1px solid var(--border-mid); border-radius: 4px; background: transparent; padding: 6px 6px 6px 14px; }
.mp-search-omnibox:focus-within { border-color: var(--gold-primary); }
.mp-search-omnibox input { color: var(--text-main); min-width: 0; flex: 1; font-size: 18px; }
.mp-search-omnibox { padding-left: 10px; }
.mp-search-omnibox .btn-battle { padding: 12px 28px; flex: none; font-size: 15px; }
@media (max-width: 1080px) { .mp-search-omnibox { min-height: 48px; } .mp-search-omnibox input { font-size: 16px; } .mp-search-omnibox .btn-battle { padding: 10px 14px; font-size: 14px; } }
.mp-search-omnibox i.search-icon { color: var(--text-muted); }

/* ---------- KPI：以細線分欄 ---------- */
.mp-kpi-strip { gap: 0; border-top: 1px solid var(--border-mid); border-bottom: 1px solid var(--border-mid); margin-bottom: 28px; }
.mp-kpi-card, .mp-kpi-card.cyan-top { background: transparent; border: 0; border-left: 1px solid var(--border-mid); border-radius: 0; padding: 16px 24px; }
.mp-kpi-card:first-child { border-left: 0; padding-left: 0; }
.mp-kpi-label { color: var(--text-muted); }
.mp-kpi-value { color: var(--text-main); }

/* ---------- 分頁籤 (榜單分類) ---------- */
.board-pills-bar { gap: 20px; border-bottom: 1px solid var(--border-mid); padding-bottom: 0; margin-bottom: 8px; }
.board-pill { background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 8px 0; margin-bottom: -1px; font-weight: 500; color: var(--text-muted); }
.board-pill:hover { color: var(--text-main); background: none; }
.board-pill.active { color: var(--text-main); font-weight: 700; background: none; border-color: var(--gold-primary); }

/* ---------- 資料時間徽章 ---------- */
.asof-chip { background: none; border: 0; border-radius: 0; padding: 0; font-size: 13px; font-weight: 500; color: var(--text-muted); }
.asof-chip i { display: none; }
.asof-row { justify-content: flex-start; margin: 0 0 8px; }

/* ---------- 首頁榜單列 ---------- */
.mp-leaderboard-head, .mp-alliance-head { padding-left: 0; padding-right: 0; color: var(--text-muted); border-bottom: 1px solid var(--border-mid); letter-spacing: 0; text-transform: none; font-weight: 500; }
.mp-board-list { gap: 0; }
.mp-board-row, .mp-board-row.top-1-row, .mp-board-row.top-2-row, .mp-board-row.top-3-row, .mp-ally-row {
    background: transparent; border: 0; border-bottom: 1px solid var(--border-subtle); border-radius: 0; padding: 12px 0; transform: none;
}
.mp-board-row:hover, .mp-ally-row:hover { background: transparent; transform: none; border-color: var(--border-subtle); }
.mp-board-row:hover .mp-gov-name { color: var(--gold-primary); text-decoration: underline; }
.mp-rank-box, .mp-rank-box.r-1, .mp-rank-box.r-2, .mp-rank-box.r-3 { background: none; border: 0; width: auto; height: auto; justify-content: flex-start; color: var(--text-muted); font-size: 14px; font-weight: 400; }
.mp-rank-box.r-1, .mp-rank-box.r-2, .mp-rank-box.r-3 { font-weight: 800; }
.mp-gov-avatar { background: var(--card-sub-bg); border: 1px solid var(--border-mid); color: var(--text-muted); border-radius: 50%; width: 36px; height: 36px; }
.mp-gov-avatar img { border-radius: 50% !important; }
.mp-gov-name { font-size: 15px; font-weight: 600; }
.mp-ally-pill { background: none; border: 0; padding: 0; color: var(--text-soft); font-weight: 400; font-size: 14px; }
.mp-ally-pill img { display: none; }
.mp-tc-pill, .mp-tc-pill.tg-badge, .mp-tc-pill.tg-max { background: none; border: 0; padding: 0; color: var(--text-soft); font-weight: 400; font-size: 14px; }
.mp-tc-pill i { display: none; }
.mp-power-main { font-size: 15px; font-weight: 700; }
.mp-ally-bar-track { background: var(--border-subtle); height: 5px; }
.mp-ally-bar-fill { background: var(--gold-primary); }
.btn-mp-more { background: none; border: 0; color: var(--gold-primary); font-weight: 600; }
.btn-mp-more:hover { background: none; color: var(--gold-primary); text-decoration: underline; }

/* ---------- 搜尋結果卡 ---------- */
.gov-basic-card { background: transparent; border: 0; border-bottom: 1px solid var(--border-subtle); border-radius: 0; }
.gov-basic-card:hover { background: var(--card-sub-bg); border-color: var(--border-subtle); }
.gov-avatar-circle { border: 1px solid var(--border-mid); background: var(--card-sub-bg); color: var(--text-muted); }

/* ---------- 按鈕 ---------- */
.btn-battle { background: var(--gold-primary); color: var(--onaccent); border: 0; border-radius: 4px; font-weight: 600; font-size: 14px; padding: 9px 18px; }
.btn-battle:hover { filter: brightness(1.08); }
.btn-battle:disabled { background: var(--border-mid); color: var(--text-muted); filter: none; }
.btn-chart-toggle, .btn-copy-link, .btn-preset, .btn-visual, .btn-layout, .pdetail-btn, .phero-retry {
    background: transparent; color: var(--text-soft); border: 1px solid var(--border-mid); border-radius: 4px; font-weight: 500;
}
.btn-chart-toggle:hover, .btn-copy-link:hover, .btn-preset:hover, .btn-visual:hover, .btn-layout:hover { background: var(--card-sub-bg); color: var(--text-main); }
.btn-chart-toggle.active, .btn-preset.active, .btn-layout.active, .btn-visual.active { background: transparent; color: var(--gold-primary); border-color: var(--gold-primary); font-weight: 700; }
.cb-label { background: none; border: 0; border-radius: 0; color: var(--text-muted); font-weight: 500; }
.cb-label:has(input:checked) { background: none; border: 0; color: var(--text-main); }

/* ---------- 輸入框 ---------- */
.kingdom-input-box, .form-field input, .form-field select, .input-group input, input[type="number"], input[type="text"] { border-radius: 4px; }
.kingdom-input-box, .input-group .kingdom-input-box { background: transparent; border: 1px solid var(--border-mid); }
.dhm-unit input { background: transparent; border: 1px solid var(--border-mid); border-radius: 4px; }
.score-preview-bar { background: transparent; border: 0; border-top: 1px solid var(--border-mid); border-bottom: 1px solid var(--border-mid); border-radius: 0; }

/* ---------- 表格 (Tabulator / data-table) ---------- */
.tabulator { background: transparent !important; border: 0 !important; font-size: 14px; }
.tabulator .tabulator-header { background: transparent !important; border-bottom: 1px solid var(--border-mid) !important; color: var(--text-muted) !important; }
.tabulator .tabulator-header .tabulator-col { background: transparent !important; border-right: 0 !important; color: var(--text-muted) !important; }
.tabulator .tabulator-header .tabulator-col .tabulator-col-content { padding: 8px 10px; }
.tabulator .tabulator-header .tabulator-col .tabulator-col-title { font-weight: 500; font-size: 12px; }
/* Tabulator midnight 主題的深灰底色 (tableholder / table / 奇偶列 / 儲存格)：用高優先權全部蓋成跟頁面一致，避免淺色模式出現深灰列 */
.tabulator .tabulator-tableholder, .tabulator .tabulator-tableholder .tabulator-table,
.tabulator .tabulator-tableholder .tabulator-table .tabulator-row,
.tabulator .tabulator-tableholder .tabulator-table .tabulator-row.tabulator-row-odd,
.tabulator .tabulator-tableholder .tabulator-table .tabulator-row.tabulator-row-even,
.tabulator .tabulator-tableholder .tabulator-table .tabulator-row .tabulator-cell,
.tabulator .tabulator-footer { background: transparent !important; background-color: transparent !important; color: var(--text-main) !important; }
.tabulator .tabulator-tableholder .tabulator-table .tabulator-row:hover,
.tabulator .tabulator-tableholder .tabulator-table .tabulator-row.row-expanded { background: var(--card-sub-bg) !important; }
.tabulator .tabulator-tableholder .tabulator-table .tabulator-row { border-bottom: 1px solid var(--border-subtle) !important; }
.tabulator-row, .tabulator-row.tabulator-row-even { background: transparent !important; border-bottom: 1px solid var(--border-subtle) !important; color: var(--text-main) !important; }
.tabulator-row:hover { background: var(--card-sub-bg) !important; }
.tabulator .tabulator-cell { border-right: 0 !important; }
.tabulator-row.row-expanded { background: var(--card-sub-bg) !important; }
.data-table th { background: transparent; color: var(--text-muted); border-bottom: 1px solid var(--border-mid); font-weight: 500; text-transform: none; }
.data-table td { border-bottom: 1px solid var(--border-subtle); }

/* ---------- 展開區 / 抽屜 ---------- */
.player-detail-drawer { background: var(--drawer-bg); border: 0; border-top: 1px solid var(--border-mid); border-bottom: 1px solid var(--border-mid); }
.drawer-card { background: transparent; border: 0; border-left: 0; border-top: 1px solid var(--border-mid); border-radius: 0; }
.drawer-card .d-label { text-transform: none; }

/* ---------- 個人頁 ---------- */
.profile-hero-banner { background: none; border: 0; border-bottom: 1px solid var(--border-mid); border-radius: 0; padding: 8px 0 20px; }
.profile-avatar-lg { width: 64px; height: 64px; border-radius: 50%; border: 1px solid var(--border-mid); background: var(--card-sub-bg); color: var(--text-muted); font-size: 26px; }
.profile-avatar-lg img { border-radius: 50% !important; }
.p-badge, .p-badge.gold, .p-badge.cyan { background: none; border: 0; padding: 0; color: var(--text-soft); font-weight: 500; }
.profile-metrics-grid { gap: 0; }
.profile-stat-box { background: transparent; border: 0; border-top: 1px solid var(--border-subtle); border-left: 0; border-radius: 0; padding: 14px 0; }
.profile-stat-box .ps-val { color: var(--text-main); }

/* ---------- 英雄卡 (個人頁 / 展開區 / 手機卡片) ---------- */
.hx-card { background: transparent; border: 1px solid var(--border-mid); border-top: 1px solid var(--border-mid); border-radius: 4px; }
.hx-chips span { background: none; border: 0; padding: 0; color: var(--text-muted); font-weight: 500; }
.hx-gears { border-top: 1px solid var(--border-subtle); }
.hc-genh.red, .hc-gt.red, .mp-gear-item.red-gear { color: var(--red) !important; }

/* ---------- 手機卡片 ---------- */
.pcard { background: transparent; border: 0; border-bottom: 1px solid var(--border-subtle); border-radius: 0; }
.pstat { background: transparent; border: 0; border-radius: 0; padding: 4px 0; }
.ppill { background: none; border: 0; color: var(--text-soft); font-weight: 500; padding: 0; }
.pally { color: var(--text-muted); font-weight: 400; }
.prank, .prank.r1, .prank.r2, .prank.r3 { background: var(--bg-dark); color: var(--text-main); border: 1px solid var(--border-mid); }
.pdetail-btn { color: var(--gold-primary); border-color: var(--gold-primary); }

/* ---------- 提示 / 橫幅 ---------- */
.notice-bar { background: transparent; border: 0; border-top: 1px solid var(--border-mid); border-bottom: 1px solid var(--border-mid); border-radius: 0; color: var(--text-soft); }
.notice-bar.warn { color: var(--warn); }
.not-home-banner { background: transparent; border: 0; border-top: 1px solid var(--warn); border-bottom: 1px solid var(--warn); border-radius: 0; color: var(--warn); }
.super-admin-banner { background: transparent; border: 0; border-bottom: 1px solid var(--border-mid); border-radius: 0; }
.chart-box, .k1-panel, .k2-panel, .tactical-toolbar, .toolbar-section { background: transparent; border-radius: 0; }
.tactical-toolbar { border: 0; border-top: 1px solid var(--border-mid); border-bottom: 1px solid var(--border-mid); }
.chart-box { border: 0; border-top: 1px solid var(--border-subtle); }
.vs-badge { color: var(--text-muted); font-weight: 600; font-size: 16px; }
.k1-panel h2, .k2-panel h2 { font-size: 16px; font-weight: 600; }
.fd-progress { background: var(--border-subtle); }

/* ---------- 全站搜尋：導覽列下方獨立一行 (跟著導覽列固定在頂端) ---------- */
.top-navbar { flex-wrap: wrap; row-gap: 0; height: auto; min-height: 0; padding-top: 0; padding-bottom: 0; }
.top-navbar > .brand-logo, .top-navbar > .top-nav-links, .top-navbar > .top-nav-actions { min-height: 68px; }
/* 搜尋框置中：三欄 (左空白 / 搜尋框 / 提示文字)，提示文字不影響置中 */
.nav-search { order: 10; flex: 1 1 100%; display: grid; grid-template-columns: minmax(0, 1fr) min(520px, 100%) minmax(0, 1fr); align-items: center; margin: 0 -28px; padding: 8px 28px 10px; border-top: 1px solid var(--border-subtle); }
.nav-search-box { grid-column: 2; }
.nav-search-box { display: flex; align-items: center; width: 100%; height: 38px; border: 1px solid var(--border-mid); border-radius: 4px; background: transparent; }
.nav-search-box:focus-within { border-color: var(--gold-primary); }
.nav-search input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; color: var(--text-main); padding: 0 10px; font-size: 14px; outline: none; font-family: inherit; }
.nav-search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.nav-search button { border: 0; background: transparent; color: var(--text-muted); width: 36px; height: 100%; cursor: pointer; font-size: 14px; }
.nav-search button:hover { color: var(--gold-primary); }
.nav-search-hint { grid-column: 3; margin-left: 14px; font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
body[data-view="dashboard"] .nav-search { display: none; }
@media (max-width: 1279px) { .nav-search-hint { display: none; } }   /* 寬度不夠放完整提示時就不顯示，避免被截斷 */
/* 第一行：標誌、選單、右側按鈕不換行 (選單寬度不夠時連結文字自己換行，和原本一樣) */
@media (min-width: 1081px) {
    .top-nav-links { flex: 1 1 0; min-width: 0; justify-content: flex-end; }
    .top-nav-actions { flex: 0 0 auto; }
    .brand-logo { flex: 0 0 auto; }
}
@media (max-width: 1080px) {
    .top-navbar > .brand-logo, .top-navbar > .top-nav-actions { min-height: 56px; }
    .top-navbar > .top-nav-links { min-height: 0; }
    .nav-search { order: 5; grid-template-columns: minmax(0, 1fr); margin: 0 -16px; padding: 8px 16px 10px; }
    .nav-search-box { grid-column: 1; }
    .nav-search-box { width: 100%; height: 40px; }
    .nav-search input { font-size: 16px; }   /* 16px 避免 iOS 聚焦時自動放大頁面 */
    .nav-search-hint { display: none; }
}

/* ---------- 手機 / 窄螢幕導覽 (漢堡選單) ---------- */
.mobile-menu-btn { background: none; border: 1px solid var(--border-mid); border-radius: 4px; color: var(--text-main); width: 38px; height: 36px; align-items: center; justify-content: center; }
@media (max-width: 1080px) {
    .top-navbar { flex-wrap: wrap; padding: 0 16px; gap: 0 12px; }
    .top-nav-links { width: 100%; order: 4; margin: 0; padding: 4px 0 0; border-top: 1px solid var(--border-subtle); }
    .top-nav-links li { width: 100%; }
    .top-nav-links li a { display: flex; width: 100%; margin: 0; padding: 14px 4px; border-bottom: 1px solid var(--border-subtle); border-left: 2px solid transparent; }
    .top-nav-links li a.active { border-bottom-color: var(--border-subtle); border-left-color: var(--gold-primary); padding-left: 12px; }
}

/* ---------- 手機 ---------- */
@media (max-width: 720px) {
    .mp-board-row { grid-template-columns: 28px minmax(0, 1fr) auto 14px; column-gap: 10px; padding: 10px 0; }
    .mp-hero-section h1 { font-size: 22px; }
    .mp-kpi-card, .mp-kpi-card.cyan-top { padding: 12px 0; border-left: 0; border-top: 1px solid var(--border-subtle); }
    .mp-kpi-card:first-child { border-top: 0; }
}
.brand-text h2 { color: var(--text-main); }

/* 王國 ID 輸入框加寬，讓提示文字完整顯示 */
.kingdom-input-box input[type="number"] { width: 124px; padding-left: 6px; padding-right: 6px; }
.kingdom-input-box input[type="number"]#limit { width: 84px; }
.kingdom-input-box input::placeholder { font-size: 13px; white-space: nowrap; }

/* ---- 後台：Tabulator 分頁列 (極簡) ---- */
.tabulator .tabulator-footer { border-top: 1px solid var(--border-mid) !important; padding: 10px 0 !important; font-size: 13px; color: var(--text-muted) !important; }
.tabulator .tabulator-footer .tabulator-paginator { text-align: right; color: var(--text-muted) !important; }
.tabulator .tabulator-footer .tabulator-page-counter { float: left; font-variant-numeric: tabular-nums; line-height: 30px; }
.tabulator .tabulator-footer .tabulator-page-size { margin: 0 8px 0 0; border: 1px solid var(--border-mid); border-radius: 4px; background: transparent; color: var(--text-main); padding: 4px 8px; font: inherit; }
.tabulator .tabulator-footer .tabulator-pages { margin: 0; }
.tabulator .tabulator-footer .tabulator-page { border: 1px solid var(--border-mid) !important; border-radius: 4px !important; background: transparent !important; color: var(--text-main) !important; padding: 4px 10px; margin: 0 0 0 4px; font: inherit; cursor: pointer; }
.tabulator .tabulator-footer .tabulator-page.active { border-color: var(--gold-primary) !important; color: var(--gold-primary) !important; font-weight: 700; }
.tabulator .tabulator-footer .tabulator-page:disabled { opacity: .4; cursor: default; }
.adm-tabs button.on { border-bottom-color: var(--gold-primary); }

/* 後台：代玩家新增填報 */
.mn-who { margin-top: 10px; font-size: 14px; min-height: 20px; }
.mn-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin-top: 10px; }
.mn-dhm { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 700; color: var(--text-muted); }
.mn-dhm > div { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr auto; gap: 4px; align-items: center; }
.mn-dhm input { width: 100%; min-width: 0; box-sizing: border-box; padding: 8px 6px; font-size: 15px; background: var(--input-bg); color: var(--text-main); border: 1px solid var(--border-mid); border-radius: 5px; text-align: center; font-family: inherit; }
.mn-dhm i { font-style: normal; font-weight: 400; }
#manualSubCard .ty-form select { width: 100%; box-sizing: border-box; padding: 8px 10px; font-size: 15px; background: var(--input-bg); color: var(--text-main); border: 1px solid var(--border-mid); border-radius: 5px; font-family: inherit; }

/* ---------- Tyrant 排行榜 (電腦版表格) ---------- */
.ty-only302 { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; cursor: pointer; user-select: none; margin-left: 6px; }
.ty-only302 input { width: 16px; height: 16px; accent-color: var(--gold-primary); }
#tableFlamedragon .tabulator-cell { font-variant-numeric: tabular-nums; }
/* 垂直置中交給欄位設定 vertAlign: "middle" (Tabulator 內建)；這裡只加大列高 */
#tableFlamedragon .tabulator-row .tabulator-cell { padding-top: 8px; padding-bottom: 8px; }
#tableFlamedragon .tabulator-row .tabulator-cell[tabulator-field="name"] { border-right: 1px solid var(--border-mid); }
.ty-gov { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ty-gov .expand-caret { flex: 0 0 auto; }
.ty-av { position: relative; flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 14px; overflow: hidden; }
.ty-av img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ty-av.r1, .ty-av.r2, .ty-av.r3 { overflow: visible; }
.ty-av.r1 img, .ty-av.r2 img, .ty-av.r3 img { border-radius: 50%; }
.ty-av.r1 { box-shadow: 0 0 0 2px var(--panel-solid, var(--bg-dark)), 0 0 0 4px #d4af37; }
.ty-av.r2 { box-shadow: 0 0 0 2px var(--panel-solid, var(--bg-dark)), 0 0 0 4px #a8b3c2; }
.ty-av.r3 { box-shadow: 0 0 0 2px var(--panel-solid, var(--bg-dark)), 0 0 0 4px #c2763a; }
.ty-nm { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.ty-nm b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 170px; }
.ty-nm small { font-size: 12px; color: var(--text-muted); font-weight: 700; }
.ty-rk { font-weight: 800; font-size: 15px; }
.ty-rk.r1 { color: #d4af37; } .ty-rk.r2 { color: #a8b3c2; } .ty-rk.r3 { color: #c2763a; }
.ty-kd { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--border-mid); color: var(--text-muted); }
.ty-kd.home { background: var(--gold-primary); border-color: var(--gold-primary); color: #111; }
body.light-mode .ty-kd.home { color: #fff; }
.ty-na { color: var(--text-muted); }
.ty-pw { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.ty-pw i { display: block; width: 86px; height: 3px; border-radius: 2px; background: var(--border-subtle); position: relative; overflow: hidden; }
.ty-pw i b { position: absolute; inset: 0 auto 0 0; background: var(--accent-cyan); border-radius: 2px; }
/* 302 的玩家：淡金色底 + 左側金線 */
#tableFlamedragon .tabulator-row.ty-home { background: rgba(212, 175, 55, 0.08) !important; box-shadow: inset 3px 0 0 var(--gold-primary); }
body.light-mode #tableFlamedragon .tabulator-row.ty-home { background: rgba(180, 83, 9, 0.07) !important; }
#tableFlamedragon .tabulator-row.ty-home .tabulator-frozen { background: inherit; }
/* 欄位分組標題 */
#tableFlamedragon .tabulator-col.ty-grp > .tabulator-col-content { padding: 4px 8px 2px; }
#tableFlamedragon .tabulator-col.ty-grp > .tabulator-col-content .tabulator-col-title { text-align: center; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); border-bottom: 2px solid var(--border-mid); padding-bottom: 3px; }
/* 排序欄：只有排序中的欄位顯示箭頭；整欄淡色底 + 粗體 */
#tableFlamedragon .tabulator-col[aria-sort="none"] .tabulator-col-sorter { visibility: hidden; }
#tableFlamedragon .tabulator-col[aria-sort="none"]:hover .tabulator-col-sorter { visibility: visible; opacity: .5; }
#tableFlamedragon[data-sort="power"] [tabulator-field="power"],
#tableFlamedragon[data-sort="migrant_score"] [tabulator-field="migrant_score"],
#tableFlamedragon[data-sort="mystic_trial"] [tabulator-field="mystic_trial"],
#tableFlamedragon[data-sort="hero_total"] [tabulator-field="hero_total"],
#tableFlamedragon[data-sort="gov_charm"] [tabulator-field="gov_charm"],
#tableFlamedragon[data-sort="gov_gear"] [tabulator-field="gov_gear"],
#tableFlamedragon[data-sort="pet_power"] [tabulator-field="pet_power"],
#tableFlamedragon[data-sort="research_power"] [tabulator-field="research_power"],
#tableFlamedragon[data-sort="kingdom"] [tabulator-field="kingdom"],
#tableFlamedragon[data-sort="name"] .tabulator-col[tabulator-field="name"] { background-image: linear-gradient(rgba(0, 180, 216, 0.08), rgba(0, 180, 216, 0.08)); font-weight: 700; color: var(--text-main); }

/* ---------- 後台：每把 API 金鑰的用量 ---------- */
.api-key-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.api-key-table th, .api-key-table td { padding: 7px 10px; border-bottom: 1px solid var(--border-subtle); text-align: left; white-space: nowrap; }
.api-key-table th { font-size: 12px; color: var(--text-muted); font-weight: 700; }
.api-key-table .mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.api-key-bar { display: inline-block; vertical-align: middle; width: 80px; height: 6px; border-radius: 3px; background: var(--border-subtle); overflow: hidden; margin-left: 6px; }
.api-key-bar i { display: block; height: 100%; }

/* ---------- 分段顯示 (前 20 → 50 → 100 名)：用分頁的第 1 頁，隱藏分頁列 ---------- */
#tableFlamedragon .tabulator-footer, .cv-tbl .tabulator-footer { display: none; }
.kv-more { display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 0 4px; }
.kv-step { font-size: 13px; color: var(--text-muted); }

/* ---------- KvK 王國對戰 ---------- */
.kv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.kv-season-l { font-size: 12px; color: var(--text-muted); font-weight: 700; }
.kv-upd { font-size: 13px; color: var(--text-muted); }
.kv-vs { display: flex; align-items: center; gap: 14px; margin: 8px 0 6px; }
.kv-k { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.kv-k.us { color: var(--gold-primary); } .kv-k.them { color: var(--k2-red); }
.kv-x { font-size: 14px; font-weight: 800; color: var(--text-muted); letter-spacing: .1em; }
.kv-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.kv-tools, .kv-mets { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.kv-mets { margin-top: 12px; gap: 6px 14px; }
.kv-base { font-size: 10px; font-weight: 800; color: #fff; background: var(--gold-primary); border-radius: 3px; padding: 0 4px; }
.kv-viz-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.kv-tiers { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.kv-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.kv-chart-t { font-size: 13px; color: var(--text-muted); font-weight: 700; margin-bottom: 6px; }
.kv-sum { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.kv-sm { border: 1px solid var(--border-subtle); border-radius: 8px; padding: 10px 12px; background: var(--card-sub-bg); }
.kv-sm-h { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 6px; }
.kv-sm-h .lead { color: #22c55e; } .kv-sm-h .lag { color: var(--k2-red); }
.kv-sm-v { display: flex; justify-content: space-between; font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.kv-sm-v .us { color: var(--gold-primary); } .kv-sm-v .them { color: var(--k2-red); }
.kv-tug { display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin-top: 6px; background: var(--border-subtle); }
.kv-tug i { display: block; background: var(--gold-primary); } .kv-tug b { display: block; background: var(--k2-red); opacity: .85; }
.kv-note { font-size: 12px; color: var(--text-muted); margin-top: 8px; }
.kv-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.kv-two.stacked { grid-template-columns: minmax(0, 1fr); }
.kv-side { min-width: 0; }
.kv-thd { display: flex; align-items: center; gap: 8px; padding: 10px 4px; font-weight: 800; border-top: 3px solid; margin-bottom: 4px; }
.kv-thd.us { color: var(--gold-primary); border-color: var(--gold-primary); } .kv-thd.them { color: var(--k2-red); border-color: var(--k2-red); }
.kv-thd span { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.cv-tbl .tabulator-cell { padding-top: 8px; padding-bottom: 8px; font-variant-numeric: tabular-nums; }
.cv-tbl .tabulator-col[aria-sort="none"] .tabulator-col-sorter { visibility: hidden; }
@media (max-width: 1080px) { .kv-two, .kv-charts { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 600px) { .cv-tbl { display: none; } }

/* 比較名單：排序中的欄位整欄淡色底 + 粗體 */
.cv-tbl[data-sort="power"] [tabulator-field="power"],
.cv-tbl[data-sort="migrant_score"] [tabulator-field="migrant_score"],
.cv-tbl[data-sort="mystic_trial"] [tabulator-field="mystic_trial"],
.cv-tbl[data-sort="hero_total"] [tabulator-field="hero_total"],
.cv-tbl[data-sort="gov_charm"] [tabulator-field="gov_charm"],
.cv-tbl[data-sort="gov_gear"] [tabulator-field="gov_gear"],
.cv-tbl[data-sort="pet_power"] [tabulator-field="pet_power"],
.cv-tbl[data-sort="research_power"] [tabulator-field="research_power"] { background-image: linear-gradient(rgba(0, 180, 216, 0.08), rgba(0, 180, 216, 0.08)); font-weight: 700; color: var(--text-main); }

/* 王國比較：輸入兩個王國 */
.kc-form { display: flex; align-items: flex-end; justify-content: center; gap: 14px; flex-wrap: wrap; }
.kc-k { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 700; }
.kc-k.us { color: var(--gold-primary); } .kc-k.them { color: var(--k2-red); }
.kc-k input { width: 150px; font-size: 18px; font-weight: 700; padding: 8px 12px; }
.kc-form .kv-x { padding-bottom: 12px; }
.kc-note { font-size: 13px; color: var(--text-muted); margin-top: 10px; text-align: center; }

/* ---------- 首頁：KvK 對戰預測 ---------- */
.fc-sub { font-size: 13px; color: var(--text-muted); margin: -4px 0 12px; }
.fc-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-bottom: 12px; }
.fc-kpi { border: 1px solid var(--border-subtle); border-radius: 8px; padding: 10px 14px; background: var(--card-sub-bg); }
.fc-kpi b { display: block; font-size: 22px; color: var(--gold-primary); font-variant-numeric: tabular-nums; line-height: 1.2; }
.fc-kpi b small { font-size: 13px; color: var(--text-muted); font-weight: 400; }
.fc-kpi span { font-size: 12px; color: var(--text-muted); }
.fc-it { display: grid; grid-template-columns: 36px 84px minmax(0, 1fr) 110px 80px; gap: 12px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--border-subtle); font-variant-numeric: tabular-nums; }
.fc-it.fc-h { font-size: 12px; font-weight: 700; color: var(--text-muted); border-bottom-color: var(--border-mid); }
.fc-it > span:nth-child(4), .fc-it > span:nth-child(5) { text-align: right; }
.fc-rk { text-align: center; font-weight: 800; color: var(--text-muted); } .fc-rk.top { color: var(--gold-primary); }
.fc-kd { font-weight: 800; font-size: 16px; }
.fc-barc { display: block; min-width: 0; }
.fc-bar { display: block; position: relative; height: 10px; border-radius: 5px; background: var(--border-subtle); }
.fc-bar i { position: absolute; top: -3px; left: 50%; width: 2px; height: 16px; background: var(--gold-primary); }
.fc-bar b { position: absolute; top: 0; height: 100%; border-radius: 5px; opacity: .85; }
.fc-bar b.up { background: var(--k2-red); } .fc-bar b.dn { background: #22c55e; }
.fc-tot { font-weight: 700; }
.fc-df { font-weight: 700; } .fc-df.up { color: var(--k2-red); } .fc-df.dn { color: #22c55e; }
.fc-note { font-size: 12px; color: var(--text-muted); margin-top: 8px; }
@media (max-width: 640px) { .fc-it { grid-template-columns: 30px 64px minmax(0, 1fr) 64px; gap: 8px; } .fc-it .fc-barc { display: none; } }

/* 首頁：對戰機率 */
.fc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.fc-head .fc-sub { margin: 4px 0 0; }
.fc-days { text-align: right; font-size: 14px; color: var(--text-muted); }
.fc-days b { font-size: 28px; color: var(--gold-primary); font-variant-numeric: tabular-nums; }
.fc-days div { font-size: 12px; }
.fc-pr { display: grid; grid-template-columns: 36px 84px minmax(0, 1fr) 72px; gap: 12px; align-items: center; padding: 9px 4px; border-bottom: 1px solid var(--border-subtle); font-variant-numeric: tabular-nums; }
.fc-pb { display: block; height: 12px; border-radius: 6px; background: var(--border-subtle); overflow: hidden; }
.fc-pb b { display: block; height: 100%; border-radius: 6px; background: var(--gold-primary); }
.fc-pp { text-align: right; font-weight: 800; font-size: 15px; }
@media (max-width: 640px) { .fc-pr { grid-template-columns: 28px 60px minmax(0, 1fr) 58px; gap: 8px; } }

/* 操作紀錄：分頁 */
.au-pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.au-pages { display: inline-flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.au-pages .cb-btn { min-width: 36px; padding: 5px 10px; }
.au-pages .cb-btn.pri { background: var(--gold-primary); border-color: var(--gold-primary); color: #fff; font-weight: 700; }
.au-pages .cb-btn:disabled { opacity: .4; cursor: default; }
.au-pager select { padding: 4px 8px; }
.au-pager label { display: inline-flex; align-items: center; gap: 6px; }
.au-pager label select { width: auto !important; min-width: 70px; }

/* 管理員登入方式 (Discord / Google) */
.login-btns { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.btn-google { background: #fff; color: #1f1f1f; border: 1px solid #dadce0; }
.btn-google i { color: #ea4335; }
.acct-host { flex: 1 1 260px; min-width: 0; }
.acct-toggle { border: 1px solid var(--border-mid); background: transparent; color: var(--text-main); border-radius: 999px; font: inherit; font-size: 12px; font-weight: 700; padding: 3px 10px; cursor: pointer; }
.acct-toggle:hover { border-color: var(--gold-primary); }
.acct-panel { margin-top: 8px; max-width: 520px; border: 1px solid var(--border-subtle); background: var(--card-sub-bg); border-radius: 8px; padding: 6px 12px; }
.acct-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border-subtle); }
.acct-row:last-of-type { border-bottom: 0; }
.acct-row > i { font-size: 18px; width: 22px; text-align: center; }
.acct-main { flex: 1; min-width: 0; display: grid; }
.acct-main span { font-size: 12px; color: var(--text-muted); overflow-wrap: anywhere; }
.acct-note { font-size: 12px; color: var(--text-muted); text-align: right; flex: 0 1 45%; min-width: 0; }
.acct-link { padding: 6px 12px; font-size: 13px; text-decoration: none; }
.acct-help { font-size: 12px; color: var(--text-muted); margin: 6px 0 4px; }
.acct-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; border: 1px solid var(--border-subtle); border-radius: 999px; padding: 2px 8px; margin: 1px 2px 1px 0; }
.acct-badge small { color: var(--text-muted); }
.adm-head { flex-wrap: wrap; align-items: flex-start; }

/* 管理員權限 */
.perm-cell { max-width: 320px; }
.perm-chip { display: inline-block; font-size: 12px; border: 1px solid var(--border-subtle); background: var(--card-sub-bg); border-radius: 999px; padding: 1px 8px; margin: 1px 4px 1px 0; }
.perm-all { font-size: 12px; font-weight: 700; color: var(--text-muted); }
.btn-del-acct { color: #ef4444 !important; }
.perm-edit-row td { background: var(--card-sub-bg); }
.perm-edit { display: grid; gap: 10px; padding: 6px 2px; }
.perm-edit-h { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
.perm-presets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--text-muted); }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 12px; }
.perm-grid label { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.perm-help { font-size: 12px; color: var(--text-muted); margin: 0; }
.perm-actions { display: flex; gap: 8px; flex-wrap: wrap; }
