/* ---------------------------------------------------------------------------
 * 比赛监控 - 深色主题样式
 * ------------------------------------------------------------------------ */

* { box-sizing: border-box; }

:root {
    --bg: #0b0e13;
    --panel: #12171f;
    --panel-2: #0d1117;
    --border: #21262d;
    --border-2: #30363d;
    --text: #e6edf3;
    --muted: #8b949e;
    --dim: #6e7681;
    --blue: #58a6ff;
    --blue-2: #1f6feb;
    --green: #2ea043;
    --green-h: #3fb950;
    --orange: #d29922;
    --red: #da3633;
    --red-h: #f85149;
    --yellow: #ffd33d;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---------------------------------------------------------------- 顶栏 */

.topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 52px;
    padding: 0 20px;
    background: #0d1117;
    border-bottom: 1px solid var(--border);
}
.topbar-icon { font-size: 20px; }
.topbar-title { color: var(--blue); font-size: 17px; font-weight: 700; letter-spacing: 1px; }
.topbar-spacer { flex: 1; }
.topbar-badge {
    font-size: 12px;
    color: var(--muted);
    border: 1px solid var(--border-2);
    border-radius: 999px;
    padding: 3px 10px;
    white-space: nowrap;
}

/* ---------------------------------------------------------------- 布局 */

.wrap {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px 20px 48px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 18px 16px;
}

.card-title {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 2px 0 4px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}
.title-bar {
    width: 4px;
    height: 16px;
    border-radius: 2px;
    background: #2f81f7;
    display: inline-block;
}
.title-action { margin-left: auto; }

/* -------------------------------------------------------------- 按钮 */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 15px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    color: #fff;
    background: #21262d;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: filter .12s ease, background .12s ease;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { filter: brightness(.95); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; margin-top: 14px; }

.btn-green { background: var(--green); }
.btn-orange { background: var(--orange); }
.btn-red { background: var(--red); }
.btn-blue { background: var(--blue-2); }
.btn-dark { background: #21262d; border-color: var(--border-2); color: #c9d1d9; }

/* -------------------------------------------------------------- 表单 */

.select-race, .select-track, input[type="text"], input[type="password"],
input[type="number"], input[type="time"], select, textarea {
    background: var(--panel-2);
    border: 1px solid var(--border-2);
    border-radius: 6px;
    color: var(--text);
    padding: 7px 10px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue-2); }
select { cursor: pointer; }
textarea { resize: vertical; min-height: 64px; width: 100%; }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}
.toolbar-label { color: var(--muted); font-size: 13px; }
.select-race { min-width: 230px; font-weight: 600; }
.select-track { min-width: 170px; }
.input-name { width: 170px; }
.input-file { font-size: 12px; color: var(--muted); max-width: 200px; }
.input-file::file-selector-button {
    background: #21262d;
    color: #c9d1d9;
    border: 1px solid var(--border-2);
    border-radius: 4px;
    padding: 4px 8px;
    margin-right: 8px;
    cursor: pointer;
    font-size: 12px;
}

/* -------------------------------------------------------------- 赛事信息 */

.race-info {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 26px;
    margin-top: 13px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
    font-size: 13.5px;
    color: var(--muted);
    line-height: 1.7;
}
.info-item { white-space: nowrap; }
.info-label { color: var(--muted); }
.info-value { color: var(--text); font-weight: 700; }
.info-value.ok { color: var(--green-h); }
.info-value.warn { color: var(--orange); }
.info-value.bad { color: var(--red-h); }
.info-value.dim { color: var(--dim); font-weight: 400; }
.count-online { color: var(--green-h); font-weight: 700; }
.count-weak { color: var(--orange); font-weight: 700; }
.count-offline { color: var(--red-h); font-weight: 700; }

/* -------------------------------------------------------------- 比赛控制 */

.control-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    margin-top: 12px;
}
.pill {
    display: inline-flex;
    align-items: center;
    padding: 6px 18px;
    border-radius: 999px;
    font-size: 13.5px;
    font-weight: 700;
    color: #fff;
    background: #6e7681;
}
.pill.pill-green { background: var(--green); }
.pill.pill-gray { background: #6e7681; }
.pill.pill-red { background: var(--red); }

.timer {
    font-family: Consolas, "Courier New", monospace;
    font-size: 40px;
    font-weight: 700;
    color: var(--yellow);
    letter-spacing: 3px;
    line-height: 1;
    text-shadow: 0 0 12px rgba(255, 211, 61, .25);
    min-width: 170px;
}

/* -------------------------------------------------------------- 表格 */

.table-scroll { overflow-x: auto; margin-top: 8px; }

.mod-table { width: 100%; border-collapse: collapse; min-width: 980px; }
.mod-table th {
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 600;
    text-align: left;
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.mod-table td {
    padding: 9px 10px;
    border-bottom: 1px solid #161b22;
    font-size: 13.5px;
    vertical-align: middle;
    white-space: nowrap;
}
.mod-table tbody tr:hover { background: rgba(88, 166, 255, .04); }
.mod-table .num {
    color: var(--blue);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.mod-table .pace {
    color: var(--orange);
    font-weight: 700;
    font-family: Consolas, monospace;
}
.empty-cell { color: var(--dim); text-align: center; padding: 26px 10px !important; }

.rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #30363d;
    color: #c9d1d9;
    font-size: 12px;
    font-weight: 700;
}
.rank.rank-1 { background: #e3a008; color: #1c1c1c; }
.rank.rank-2 { background: #8b949e; color: #1c1c1c; }
.rank.rank-3 { background: #e5534b; color: #fff; }

.st { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; }
.st .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.st-online { color: var(--green-h); }
.st-weak { color: var(--orange); }
.st-offline { color: var(--red-h); }
.st-online .dot { box-shadow: 0 0 6px rgba(63, 185, 80, .9); }

.mod-name { font-weight: 700; color: #fff; font-size: 13.5px; }
.mod-tag { font-size: 11.5px; color: var(--dim); font-family: Consolas, monospace; margin-top: 2px; }

.inp-start {
    width: 86px;
    text-align: right;
    background: var(--panel-2);
    border: 1px solid var(--blue-2);
    border-radius: 4px;
    color: var(--blue);
    padding: 5px 7px;
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    outline: none;
}
.inp-start:focus { box-shadow: 0 0 0 2px rgba(31, 111, 235, .35); }

.th-ops { text-align: right; }
.ops { text-align: right; }
.icon-btn {
    background: transparent;
    border: none;
    color: #30363d;
    font-size: 15px;
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 4px;
    line-height: 1;
}
.icon-btn:hover { color: var(--text); background: #21262d; }
.icon-btn.act-leader.on { color: var(--yellow); }
.icon-btn.act-leader { color: #484f58; }

/* -------------------------------------------------------------- 轨迹列表 */

.track-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    min-height: 8px;
}
.track-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid var(--border-2);
    background: var(--panel-2);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 12.5px;
    color: #c9d1d9;
    cursor: pointer;
    user-select: none;
}
.track-item:hover { border-color: var(--blue-2); }
.track-item.active { border-color: var(--blue-2); background: rgba(31, 111, 235, .15); }
.track-item input { accent-color: var(--blue-2); cursor: pointer; }
.track-item .t-len { color: var(--blue); font-weight: 700; }
.track-item .t-type { color: var(--dim); font-size: 11px; }
.track-empty { color: var(--dim); font-size: 12.5px; }

.map-box {
    height: 430px;
    margin-top: 10px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: #0d1117;
}

/* 地图模块标记 */
.mod-pin { display: flex; align-items: center; gap: 4px; pointer-events: none; }
.mod-pin-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2.5px solid #fff;
    box-shadow: 0 0 6px rgba(0, 0, 0, .65);
    flex: none;
}
.mod-pin-dot.online { animation: pinPulse 1.6s ease-in-out infinite; }
.mod-pin-label {
    background: rgba(13, 17, 23, .88);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 4px;
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, .15);
}
@keyframes pinPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.25); }
}

/* -------------------------------------------------------------- 弹窗 */

.modal-root {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .62);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}
.modal {
    background: #161b22;
    border: 1px solid var(--border-2);
    border-radius: 10px;
    width: 520px;
    max-width: 96vw;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px 22px 22px;
}
.modal.modal-wide { width: 820px; }
.modal h3 { margin: 0 0 6px; font-size: 16px; color: var(--text); }
.modal .modal-sub { color: var(--muted); font-size: 12.5px; margin: 0 0 8px; line-height: 1.6; }
.modal label { display: block; font-size: 12.5px; color: var(--muted); margin: 12px 0 4px; }
.modal input[type="text"], .modal input[type="password"],
.modal input[type="number"], .modal select { width: 100%; }
.modal .row2 { display: flex; gap: 12px; }
.modal .row2 > div { flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.settings-section { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 6px; }
.settings-section h4 { color: var(--blue); font-size: 13.5px; margin: 10px 0 2px; }
.settings-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 14px; }
.settings-grid.two { grid-template-columns: repeat(2, 1fr); }
.settings-grid .full { grid-column: 1 / -1; }
.settings-grid label { margin-top: 0; }
.check-line { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 13px; color: var(--text); }
.check-line input { accent-color: var(--blue-2); width: 15px; height: 15px; }
.hint { font-size: 12px; color: var(--dim); margin-top: 4px; line-height: 1.6; }
.ingest-box {
    background: var(--panel-2);
    border: 1px solid var(--border-2);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 12.5px;
    color: #c9d1d9;
    line-height: 1.8;
    word-break: break-all;
}
.ingest-box code { color: var(--blue); font-family: Consolas, monospace; }

/* -------------------------------------------------------------- 提示条 */

.toast {
    position: fixed;
    right: 22px;
    bottom: 24px;
    z-index: 3000;
    background: #1f6feb;
    color: #fff;
    padding: 11px 17px;
    border-radius: 8px;
    font-size: 13.5px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .45);
    max-width: 380px;
    transition: opacity .25s ease;
}
.toast.error { background: var(--red); }
.toast.info { background: #21262d; border: 1px solid var(--border-2); }

/* -------------------------------------------------------------- 登录/初始化 */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(1000px 500px at 20% -10%, rgba(31, 111, 235, .12), transparent),
        radial-gradient(800px 500px at 100% 110%, rgba(46, 160, 67, .08), transparent),
        var(--bg);
    padding: 24px;
}
.auth-card {
    width: 380px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px;
}
.auth-logo { font-size: 18px; font-weight: 700; color: var(--blue); margin-bottom: 14px; }
.auth-card h1 { font-size: 17px; margin: 0 0 6px; }
.auth-sub { color: var(--muted); font-size: 12.5px; line-height: 1.7; margin: 0 0 12px; }
.auth-card label { display: block; font-size: 12.5px; color: var(--muted); margin: 12px 0 4px; }
.auth-card input {
    width: 100%;
    background: var(--panel-2);
    border: 1px solid var(--border-2);
    border-radius: 6px;
    color: var(--text);
    padding: 9px 11px;
    font-size: 14px;
    outline: none;
}
.auth-card input:focus { border-color: var(--blue-2); }
.alert {
    background: rgba(248, 81, 73, .12);
    border: 1px solid var(--red-h);
    color: #ffa198;
    border-radius: 6px;
    padding: 8px 11px;
    font-size: 13px;
    margin-top: 10px;
}
.auth-back { display: inline-block; margin-top: 14px; color: var(--blue); font-size: 13px; text-decoration: none; }

/* -------------------------------------------------------------- 响应式 */

@media (max-width: 900px) {
    .timer { font-size: 32px; }
    .wrap { padding: 12px 10px 40px; }
    .card { padding: 12px 12px 14px; }
    .settings-grid { grid-template-columns: repeat(2, 1fr); }
    .topbar { padding: 0 10px; }
    .topbar-badge { display: none; }
}
