/* ===== CSS Variables ===== */
:root {
    --gold: #c8a44a;
    --gold-light: #e8c96a;
    --gold-dark: #8b6a20;
    --bg-deep: #0a0c12;
    --bg-card: #111520;
    --bg-card2: #161b28;
    --border: rgba(200, 164, 74, 0.3);
    --border-hover: rgba(200, 164, 74, 0.7);
    --text-primary: #e8d8b0;
    --text-secondary: #9a8a6a;
    --text-muted: #5a5040;
    --tank-color: #4a90d9;
    --tank-bg: rgba(74, 144, 217, 0.1);
    --healer-color: #6abf6a;
    --healer-bg: rgba(106, 191, 106, 0.1);
    --damage-color: #d94a4a;
    --damage-bg: rgba(217, 74, 74, 0.1);
    --shadow: 0 4px 24px rgba(0,0,0,0.6);
    --glow-gold: 0 0 12px rgba(200, 164, 74, 0.3);
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15.5px; }
body {
    background-color: var(--bg-deep);
    color: var(--text-primary);
    font-family: 'Noto Sans SC', Georgia, sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* ===== Background ===== */
.bg-overlay {
    position: fixed; inset: 0;
    background:
        radial-gradient(ellipse 80% 40% at 50% 0%, rgba(200,164,74,0.06) 0%, transparent 60%),
        radial-gradient(ellipse 60% 60% at 80% 100%, rgba(74,90,180,0.08) 0%, transparent 60%),
        repeating-linear-gradient(45deg, transparent, transparent 60px, rgba(200,164,74,0.015) 60px, rgba(200,164,74,0.015) 61px);
    pointer-events: none; z-index: 0;
}

/* ===== Header ===== */
.site-header {
    position: relative; z-index: 1;
    padding: 28px 40px 0;
    text-align: center;
}
.header-inner {
    display: flex; align-items: center;
    justify-content: center; gap: 20px;
}
.header-emblem {
    font-size: 2rem;
    filter: drop-shadow(0 0 8px rgba(200,164,74,0.5));
}
.site-header h1 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 2.4rem; font-weight: 900;
    background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 50%, var(--gold-dark) 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    letter-spacing: 0.1em; line-height: 1.1;
}
.subtitle {
    font-family: 'Noto Sans SC', sans-serif;
    color: var(--text-secondary); font-size: 0.85rem;
    letter-spacing: 0.2em; margin-top: 4px;
}
.header-divider {
    height: 1px; margin: 20px auto 0; max-width: 700px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    position: relative;
}
.header-divider::before {
    content: '✦'; position: absolute; left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    color: var(--gold); font-size: 0.7rem;
    background: var(--bg-deep); padding: 0 8px;
}

/* ===== Main Layout — 三栏 ===== */
.main-layout {
    position: relative; z-index: 1;
    display: grid;
    grid-template-columns: 260px 1fr 220px;
    gap: 24px;
    max-width: 1280px;
    margin: 28px auto;
    padding: 0 24px 40px;
    align-items: start;
}

/* ===== 共用面板基础样式 ===== */
.stats-panel, .action-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 20px;
    box-shadow: var(--shadow), inset 0 1px 0 rgba(200,164,74,0.1);
    position: sticky;
    top: 20px;
}

/* ===== 左侧：队伍概览 ===== */
.panel-title {
    font-family: 'Cormorant Garamond', serif;
    color: var(--gold); font-size: 1rem;
    letter-spacing: 0.15em; text-align: center;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}
.stats-grid { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.stat-card {
    border-radius: 4px; padding: 12px 14px;
    border: 1px solid transparent;
    display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.stat-card:hover { box-shadow: 0 0 10px rgba(0,0,0,0.4); }
.tank-card { background: var(--tank-bg); border-color: rgba(74,144,217,0.2); }
.healer-card { background: var(--healer-bg); border-color: rgba(106,191,106,0.2); }
.damage-card { background: var(--damage-bg); border-color: rgba(217,74,74,0.2); }
.stat-icon { font-size: 1.3rem; }
.stat-label { font-size: 0.85rem; color: var(--text-secondary); letter-spacing: 0.05em; }
.stat-count { font-family: 'Cormorant Garamond', serif; font-size: 1.6rem; font-weight: 900; line-height: 1; }
.tank-card .stat-count { color: var(--tank-color); }
.healer-card .stat-count { color: var(--healer-color); }
.damage-card .stat-count { color: var(--damage-color); }
.stat-icons-row {
    grid-column: 1 / -1; display: flex; flex-wrap: wrap;
    gap: 5px; margin-top: 6px; min-height: 0;
}
.role-badge {
    display: inline-flex; align-items: center; gap: 4px;
    background: rgba(0,0,0,0.3); border-radius: 20px;
    padding: 2px 7px 2px 3px; font-size: 0.72rem;
    color: var(--text-secondary); border: 1px solid rgba(255,255,255,0.06);
}
.role-badge img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; }
.total-bar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 0; border-top: 1px solid var(--border);
    color: var(--text-secondary); font-size: 0.85rem;
}
.total-count { font-family: 'Cormorant Garamond', serif; font-size: 1.3rem; color: var(--gold); font-weight: 600; }
.sync-status {
    display: flex; align-items: center; gap: 6px;
    margin-top: 10px; font-size: 0.75rem; color: var(--text-muted);
}
.status-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: #6abf6a; flex-shrink: 0; transition: background 0.3s;
}
.panel-gif-wrapper {
    margin-top: 16px; border-top: 1px solid var(--border);
    padding-top: 14px; text-align: center;
}
.panel-gif { width: 100%; max-width: 220px; height: auto; border-radius: 6px; opacity: 0.85; }

/* ===== 中间：表格区域 ===== */
.table-section { display: flex; flex-direction: column; gap: 10px; }

/* 筛选按钮 */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-btn {
    padding: 6px 14px;
    background: transparent;
    border: 1px solid rgba(200,164,74,0.2);
    color: var(--text-muted);
    border-radius: 20px; cursor: pointer;
    font-family: 'Noto Sans SC', sans-serif;
    font-size: 0.78rem;
    transition: all 0.2s;
}
.filter-btn:hover { border-color: var(--gold-dark); color: var(--text-secondary); }
.filter-btn.active {
    background: rgba(200,164,74,0.15);
    border-color: var(--gold);
    color: var(--gold-light);
}

/* 表格容器：高度由内部 tbody 控制 */
.table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    box-shadow: var(--shadow);
}
#signupTable { width: 100%; border-collapse: collapse; display: flex; flex-direction: column; }
#signupTable thead { display: block; width: 100%; flex-shrink: 0; }
#signupTable tbody {
    display: block;
    overflow-y: auto;
    max-height: calc(100vh - 280px);
    scrollbar-width: thin;
    scrollbar-color: var(--gold-dark) transparent;
}
#signupTable thead tr,
#signupTable tbody tr { display: table; width: 100%; table-layout: fixed; }
#signupTable thead tr {
    background: linear-gradient(135deg, #1a1520 0%, #161220 100%);
    border-bottom: 1px solid var(--gold-dark);
}
#signupTable th {
    padding: 13px 14px; text-align: left;
    font-family: 'Cormorant Garamond', serif; font-size: 0.75rem;
    font-weight: 600; color: var(--gold);
    letter-spacing: 0.12em; text-transform: uppercase;
}
#signupTable tbody tr {
    border-bottom: 1px solid rgba(200,164,74,0.08);
    transition: background 0.15s;
    animation: rowIn 0.3s ease forwards;
}
@keyframes rowIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
#signupTable tbody tr:hover { background: rgba(200,164,74,0.04); }
#signupTable tbody tr:last-child { border-bottom: none; }
#signupTable td { padding: 10px 14px; vertical-align: middle; }

/* 隐藏筛选后的行 */
#signupTable tbody tr.filter-hidden { display: none; }

/* 列宽 */
.col-name { width: 18%; }
.col-main { width: 26%; }
.col-alt  { width: 26%; }
.col-note { width: 22%; }
.col-action { width: 8%; }

/* ===== 表单元素 ===== */
#signupTable input[type="text"] {
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(200,164,74,0.2);
    border-radius: 3px; color: var(--text-primary);
    padding: 7px 10px;
    font-family: 'Noto Sans SC', sans-serif; font-size: 0.82rem;
    width: 100%; transition: border-color 0.2s, box-shadow 0.2s;
    outline: none; -webkit-appearance: none;
}
#signupTable input[type="text"]:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(200,164,74,0.15);
}
#signupTable input::placeholder { color: var(--text-muted); }
#signupTable input:disabled { cursor: default; }

/* ===== 按钮 ===== */
.btn-delete {
    background: transparent;
    border: 1px solid rgba(217,74,74,0.3);
    color: rgba(217,100,100,0.7);
    padding: 5px 10px; border-radius: 3px;
    cursor: pointer; font-size: 0.75rem;
    transition: all 0.2s; white-space: nowrap;
}
.btn-delete:hover { background: rgba(217,74,74,0.15); border-color: rgba(217,74,74,0.7); color: #d96060; }

.btn-lock {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-muted);
    padding: 5px 10px; border-radius: 3px;
    cursor: pointer; font-size: 0.75rem;
    transition: all 0.2s; white-space: nowrap;
}
.btn-lock:hover { border-color: var(--gold-dark); color: var(--gold); }

/* ===== 空行 ===== */
.empty-row td {
    text-align: center; padding: 36px;
    color: var(--text-muted); font-style: italic; font-size: 0.88rem;
}

/* ===== 右侧：操作面板 ===== */
.action-panel { display: flex; flex-direction: column; gap: 0; }

.action-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 4px; }
.action-field { display: flex; flex-direction: column; gap: 5px; }
.action-field label { font-size: 0.74rem; color: var(--text-secondary); letter-spacing: 0.05em; }
.action-input {
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(200,164,74,0.25);
    border-radius: 4px; color: var(--text-primary);
    padding: 8px 10px;
    font-family: 'Noto Sans SC', sans-serif; font-size: 0.82rem;
    outline: none; width: 100%;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.action-input:focus { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(200,164,74,0.15); }
.action-input::placeholder { color: var(--text-muted); }

.action-hint { font-size: 0.72rem; color: var(--text-muted); line-height: 1.5; }

.btn-add {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 14px; width: 100%;
    background: linear-gradient(135deg, rgba(200,164,74,0.15) 0%, rgba(200,164,74,0.08) 100%);
    border: 1px solid var(--gold-dark); color: var(--gold-light);
    font-family: 'Cormorant Garamond', serif; font-size: 0.78rem; font-weight: 600;
    letter-spacing: 0.08em; border-radius: 4px; cursor: pointer;
    transition: all 0.2s; box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.btn-add:hover {
    background: linear-gradient(135deg, rgba(200,164,74,0.25) 0%, rgba(200,164,74,0.15) 100%);
    border-color: var(--gold); box-shadow: var(--glow-gold), 0 2px 8px rgba(0,0,0,0.4);
    transform: translateY(-1px);
}
.btn-add:active { transform: translateY(0); }
.btn-icon { font-size: 1rem; line-height: 1; }

/* 报名反馈 */
.panel-feedback {
    font-size: 0.78rem; text-align: center; min-height: 1.2em;
    color: var(--healer-color); transition: opacity 0.3s;
}

.action-divider {
    height: 1px; margin: 14px 0;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
}

.action-admin { display: flex; flex-direction: column; gap: 8px; }

.btn-admin {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 14px; width: 100%;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-muted);
    font-family: 'Cormorant Garamond', serif; font-size: 0.76rem; font-weight: 600;
    letter-spacing: 0.08em; border-radius: 4px; cursor: pointer;
    transition: all 0.2s;
}
.btn-admin:hover { border-color: var(--gold-dark); color: var(--gold); }

.btn-clear {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 14px; width: 100%;
    background: transparent;
    border: 1px solid rgba(217,74,74,0.3);
    color: rgba(217,100,100,0.7);
    font-family: 'Cormorant Garamond', serif; font-size: 0.76rem; font-weight: 600;
    letter-spacing: 0.08em; border-radius: 4px; cursor: pointer;
    transition: all 0.2s;
}
.btn-clear:hover { background: rgba(217,74,74,0.12); border-color: rgba(217,74,74,0.7); color: #f08080; }

.action-contact {
    font-size: 0.72rem; color: var(--text-muted);
    text-align: center; line-height: 1.7;
}
.action-contact strong { color: var(--gold); font-weight: 600; }

/* ===== 自定义下拉框 ===== */
.custom-select { position: relative; width: 100%; user-select: none; }
.custom-select-selected {
    display: flex; align-items: center; gap: 6px;
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(200,164,74,0.2);
    border-radius: 3px; color: var(--text-primary);
    padding: 6px 10px;
    font-family: 'Noto Sans SC', sans-serif; font-size: 0.82rem;
    cursor: pointer; transition: border-color 0.2s, box-shadow 0.2s;
    min-height: 34px;
}
.custom-select-selected img { width: 20px; height: 20px; border-radius: 3px; object-fit: cover; flex-shrink: 0; }
.custom-select-selected span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-arrow { flex: 0 !important; color: var(--gold); font-size: 0.75rem; transition: transform 0.2s; }
.custom-select.open .custom-select-selected { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(200,164,74,0.15); }
.custom-select.open .cs-arrow { transform: rotate(180deg); }
.cs-placeholder { color: var(--text-muted); }
.custom-select-dropdown {
    display: none; position: fixed; z-index: 9999;
    background: #1a1e2e; border: 1px solid var(--gold-dark);
    border-radius: 4px; box-shadow: 0 8px 24px rgba(0,0,0,0.7);
    max-height: 300px; overflow-y: auto;
    scrollbar-width: thin; scrollbar-color: var(--gold-dark) transparent;
}
.custom-select-group-label {
    padding: 6px 10px 4px; font-size: 0.68rem;
    color: var(--gold-dark); letter-spacing: 0.1em;
    pointer-events: none;
    border-top: 1px solid rgba(200,164,74,0.1); margin-top: 2px;
}
.custom-select-group-label:first-child { border-top: none; margin-top: 0; }
.custom-select-option {
    display: flex; align-items: center; gap: 7px;
    padding: 6px 10px; font-size: 0.82rem;
    color: var(--text-secondary); cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.custom-select-option img { width: 22px; height: 22px; border-radius: 3px; object-fit: cover; flex-shrink: 0; }
.custom-select-option:hover { background: rgba(200,164,74,0.1); color: var(--text-primary); }
.custom-select-option.active { background: rgba(200,164,74,0.15); color: var(--gold-light); }
.custom-select.cs-disabled .custom-select-selected { cursor: default; }

/* ===== 拖拽排序 ===== */
.drag-handle {
    display: inline-block; margin-right: 8px;
    color: var(--text-muted); cursor: grab;
    font-size: 1rem; line-height: 1;
    vertical-align: middle; user-select: none;
    transition: color 0.2s;
}
.drag-handle:hover { color: var(--gold); }
.drag-handle:active { cursor: grabbing; }
#tableBody tr.dragging { opacity: 0.4; background: rgba(200,164,74,0.05); }
#tableBody tr.drag-over { border-top: 2px solid var(--gold); background: rgba(200,164,74,0.08); }

/* ===== 弹窗 ===== */
.modal-overlay {
    position: fixed; inset: 0; z-index: 100000;
    background: rgba(0,0,0,0.75);
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
}
.modal-box {
    background: #161b28; border: 1px solid var(--gold-dark);
    border-radius: 8px; padding: 28px 32px;
    width: 360px; max-width: 92vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.85);
}
.modal-title { font-family: 'Cormorant Garamond', serif; color: var(--gold); font-size: 1.05rem; margin-bottom: 10px; letter-spacing: 0.1em; }
.modal-desc { color: var(--text-secondary); font-size: 0.82rem; margin-bottom: 16px; line-height: 1.6; }
.modal-field { margin-bottom: 12px; }
.modal-field label { display: block; font-size: 0.76rem; color: var(--text-secondary); margin-bottom: 5px; letter-spacing: 0.05em; }
.modal-input {
    width: 100%; background: rgba(0,0,0,0.4);
    border: 1px solid rgba(200,164,74,0.25); border-radius: 4px;
    color: var(--text-primary); padding: 9px 12px;
    font-family: 'Noto Sans SC', sans-serif; font-size: 0.88rem;
    outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
.modal-input:focus { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(200,164,74,0.15); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.modal-cancel {
    background: transparent; border: 1px solid rgba(255,255,255,0.12);
    color: var(--text-secondary); padding: 8px 18px; border-radius: 4px;
    cursor: pointer; font-size: 0.82rem; transition: all 0.2s;
}
.modal-cancel:hover { border-color: rgba(255,255,255,0.3); color: var(--text-primary); }
.modal-confirm {
    background: linear-gradient(135deg, rgba(200,164,74,0.22), rgba(200,164,74,0.1));
    border: 1px solid var(--gold-dark); color: var(--gold-light);
    padding: 8px 22px; border-radius: 4px; cursor: pointer;
    font-family: 'Cormorant Garamond', serif; font-size: 0.82rem; font-weight: 600;
    letter-spacing: 0.08em; transition: all 0.2s;
}
.modal-confirm:hover { background: linear-gradient(135deg, rgba(200,164,74,0.32), rgba(200,164,74,0.18)); border-color: var(--gold); box-shadow: var(--glow-gold); }

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .main-layout { grid-template-columns: 1fr; padding: 0 14px 30px; }
    .stats-panel, .action-panel { position: static; }
    .site-header { padding: 20px 20px 0; }
    .site-header h1 { font-size: 1.6rem; }
    #signupTable { font-size: 0.78rem; }
    .table-wrapper { max-height: 400px; }
}

/* ===== 漫画按钮 ===== */
.btn-comic {
    width: 100%;
    background: transparent;
    border: 1px dashed rgba(200,164,74,0.2);
    color: var(--text-muted);
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Noto Sans SC', sans-serif;
    font-size: 0.74rem;
    letter-spacing: 0.05em;
    transition: all 0.3s;
    text-align: center;
}
.btn-comic:hover {
    border-color: rgba(200,164,74,0.5);
    color: var(--text-secondary);
    background: rgba(200,164,74,0.04);
}

/* ===== 漫画弹窗 ===== */
.comic-overlay {
    position: fixed; inset: 0; z-index: 100000;
    background: rgba(0,0,0,0.85);
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(6px);
}
.comic-box {
    position: relative;
    background: #0f1319;
    border: 1px solid var(--gold-dark);
    border-radius: 10px;
    padding: 16px;
    max-width: 92vw;
    max-height: 92vh;
    box-shadow: 0 0 60px rgba(200,164,74,0.12), 0 20px 60px rgba(0,0,0,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.comic-box::before {
    content: '';
    position: absolute; inset: -1px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(200,164,74,0.3), transparent 40%, transparent 60%, rgba(200,164,74,0.15));
    pointer-events: none;
    z-index: -1;
}
.comic-title {
    font-family: 'Cormorant Garamond', serif;
    color: var(--gold); font-size: 0.9rem;
    letter-spacing: 0.2em; text-align: center;
}
.comic-img {
    max-width: 100%;
    max-height: calc(92vh - 100px);
    border-radius: 6px;
    object-fit: contain;
    display: block;
}
.comic-close {
    position: absolute; top: 10px; right: 14px;
    background: transparent; border: none;
    color: var(--text-muted); font-size: 1.2rem;
    cursor: pointer; line-height: 1;
    transition: color 0.2s;
}
.comic-close:hover { color: var(--gold); }

/* ===== Toast 提示（替代 alert）===== */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1e2336;
    border: 1px solid var(--gold-dark);
    color: var(--text-primary);
    padding: 10px 22px;
    border-radius: 6px;
    font-size: 0.85rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
    opacity: 0;
    transition: opacity 0.25s, transform 0.25s;
    z-index: 200000;
    white-space: nowrap;
    pointer-events: none;
}
.toast.toast-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.toast.toast-error {
    border-color: rgba(217,74,74,0.6);
    color: #f08080;
}

/* ===== 危险确认按钮 ===== */
.modal-confirm-danger {
    background: rgba(217,74,74,0.2) !important;
    border-color: #d94a4a !important;
    color: #f08080 !important;
}
.modal-confirm-danger:hover {
    background: rgba(217,74,74,0.35) !important;
    box-shadow: 0 0 12px rgba(217,74,74,0.3) !important;
}

/* ===== 同步中状态点（金色）===== */
.status-dot.syncing { background: var(--gold) !important; }
