/* ======== 鸣蝉体测 · 超管后台 v2 ======== */

:root {
    --primary: #3056d3;
    --primary-dark: #2445b0;
    --danger: #d93025;
    --bg: #f4f6fb;
    --card: #ffffff;
    --text: #1f2733;
    --text-2: #5b6675;
    --text-3: #8a94a3;
    --line: #e5eaf2;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(23, 43, 77, .06), 0 4px 16px rgba(23, 43, 77, .06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.mono { font-family: 'SF Mono', Menlo, Consolas, monospace; letter-spacing: .5px; }

/* ======== 视图切换 ======== */

.view { display: none; min-height: 100vh; }
.view.active { display: block; }

/* ======== 登录页 ======== */

#loginPage.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(160deg, #eef2fb 0%, #f7f4ee 100%);
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--card);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 40px 32px 32px;
    text-align: center;
}

.login-logo {
    width: 64px; height: 64px;
    margin: 0 auto 16px;
    border-radius: 18px;
    overflow: hidden;
    display: flex; align-items: center; justify-content: center;
}
.login-logo svg { width: 100%; height: 100%; display: block; }

.login-title { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.login-sub { color: var(--text-3); font-size: 13px; margin-bottom: 24px; }

.login-input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    font-size: 15px;
    outline: none;
    transition: border-color .2s;
    margin-bottom: 16px;
}
.login-input:focus { border-color: var(--primary); }

.login-hint { color: var(--text-3); font-size: 12px; margin-top: 14px; }

/* ======== 按钮 ======== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: none;
    border-radius: 9px;
    padding: 9px 16px;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s, opacity .15s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:not(:disabled):hover { background: var(--primary-dark); }

.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: rgba(48, 86, 211, .08); }
.btn-ghost.danger { color: var(--danger); }
.btn-ghost.danger:hover { background: rgba(217, 48, 37, .08); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:not(:disabled):hover { background: #b8251c; }

.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 7px; }

/* ======== 顶栏 ======== */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}

.topbar-brand { display: flex; align-items: center; gap: 10px; }

.brand-logo {
    width: 34px; height: 34px;
    border-radius: 10px;
    overflow: hidden;
    display: flex; align-items: center; justify-content: center;
}
.brand-logo svg { width: 100%; height: 100%; display: block; }

.brand-title { font-size: 16px; font-weight: 700; }

.topbar-actions { display: flex; gap: 4px; }

/* ======== 主内容 ======== */

.page {
    max-width: 1080px;
    margin: 0 auto;
    padding: 20px 20px 60px;
}

/* 统计条 */
.stats-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 18px;
}

.stat-tile {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
}
.stat-tile b { font-size: 24px; font-weight: 700; color: var(--primary); line-height: 1.3; }
.stat-tile span { color: var(--text-3); font-size: 12px; }

/* 工具栏 */
.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 180px;
    padding: 10px 14px;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    background: var(--card);
    transition: border-color .2s;
}
.search-input:focus { border-color: var(--primary); }

.toolbar-btns { display: flex; gap: 8px; }

/* ======== 学校卡片 ======== */

.school-list { display: flex; flex-direction: column; gap: 14px; }

.school-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px 14px;
    transition: box-shadow .2s;
}
.school-card:hover { box-shadow: 0 2px 6px rgba(23, 43, 77, .08), 0 8px 24px rgba(23, 43, 77, .1); }
.school-card.inactive { opacity: .68; }

.sc-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.sc-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sc-title h3 { font-size: 17px; font-weight: 700; }

.sc-created { color: var(--text-3); font-size: 12px; }

.sc-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 12px 0 8px;
}

.chip {
    background: #f1f4fa;
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 12.5px;
    color: var(--text-2);
}
.chip b { color: var(--text); font-weight: 700; }
.chip-hl { background: #e8f0fe; color: var(--primary); }
.chip-hl b { color: var(--primary); }

.sc-roles { color: var(--text-3); font-size: 12px; margin-bottom: 10px; }

.sc-actions {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    border-top: 1px solid var(--line);
    padding-top: 8px;
    margin: 0 -6px;
}

/* ======== 徽章 ======== */

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}
.badge-green { background: #d9f2dd; color: #1e7b34; }
.badge-blue { background: #dbe9fb; color: #1d5fbf; }
.badge-amber { background: #fff4ce; color: #9a6700; }
.badge-red { background: #fbdcda; color: #c0392b; }
.badge-purple { background: #ece4fb; color: #6b3fc4; }
.badge-gray { background: #eef0f4; color: #6b7686; }

/* ======== 弹窗 ======== */

.overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(15, 23, 42, .45);
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.overlay.show { display: flex; }

.dialog {
    background: var(--card);
    border-radius: 16px;
    width: 100%;
    max-width: 460px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 48px rgba(15, 23, 42, .25);
}
.dialog-wide { max-width: 640px; }

.dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--line);
}
.dialog-head h3 { font-size: 16px; font-weight: 700; }

.dialog-x {
    border: none; background: none;
    font-size: 15px; color: var(--text-3);
    cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.dialog-x:hover { background: #f1f4fa; }

.dialog-body { padding: 16px 20px; overflow-y: auto; }

.dialog-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px 16px;
    border-top: 1px solid var(--line);
}

/* 表单 */
.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }

.field-input {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--line);
    border-radius: 9px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color .2s;
}
.field-input:focus { border-color: var(--primary); }

.field-row { display: flex; gap: 6px; align-items: center; }
.field-row .field-input { flex: 1; }

.field-help { display: block; color: var(--text-3); font-size: 12px; margin-top: 5px; line-height: 1.55; }
.stage-row { display: flex; gap: 8px 18px; flex-wrap: wrap; }
.stage-check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text); cursor: pointer; }
.stage-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); }

.danger-text { color: var(--text-2); font-size: 13.5px; margin-bottom: 14px; }
.danger-text b { color: var(--danger); }

/* ======== 入住码列表 ======== */

.codes-intro {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--text-3);
    font-size: 12.5px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.codes-list { display: flex; flex-direction: column; gap: 10px; }

.code-row {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.code-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.code-text {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    background: #f1f4fa;
    padding: 2px 10px;
    border-radius: 7px;
}

.code-meta { display: flex; gap: 14px; color: var(--text-3); font-size: 12px; flex-wrap: wrap; }
.code-actions { display: flex; gap: 4px; margin: 0 -6px; }

/* ======== 成员列表 ======== */

.members-list { display: flex; flex-direction: column; gap: 10px; }

.member-row {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.member-main { display: flex; align-items: center; gap: 8px; min-width: 140px; }
.member-name { font-weight: 600; }

.member-meta {
    flex: 1;
    display: flex;
    gap: 14px;
    color: var(--text-3);
    font-size: 12px;
    flex-wrap: wrap;
}

.member-actions { margin-left: auto; }

/* ======== 空状态/加载 ======== */

.empty-state {
    background: var(--card);
    border-radius: var(--radius);
    padding: 48px 20px;
    text-align: center;
    color: var(--text-3);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.empty-state .err { color: var(--danger); }

.spinner {
    width: 26px; height: 26px;
    border: 3px solid var(--line);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ======== Toast ======== */

.toast {
    position: fixed;
    left: 50%;
    bottom: 32px;
    transform: translateX(-50%) translateY(20px);
    background: #232a36;
    color: #fff;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    max-width: 86vw;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s, transform .25s;
    z-index: 99;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

/* ======== 手机适配 ======== */

@media (max-width: 640px) {
    .page { padding: 14px 12px 48px; }

    .topbar { padding: 8px 12px; }
    .brand-title { font-size: 14px; }

    .stats-strip { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-tile { padding: 12px 14px; }
    .stat-tile b { font-size: 20px; }

    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar-btns { justify-content: space-between; }
    .toolbar-btns .btn { flex: 1; }

    .school-card { padding: 14px 14px 10px; }
    .sc-title h3 { font-size: 16px; }
    .sc-actions .btn { flex: 1 1 30%; }

    .overlay { padding: 0; align-items: flex-end; }
    .dialog, .dialog-wide {
        max-width: 100%;
        max-height: 92vh;
        border-radius: 16px 16px 0 0;
    }

    .member-actions { margin-left: 0; width: 100%; }
    .codes-intro { flex-direction: column; align-items: stretch; }
}

/* ===== 学生信息弹窗(名单+学籍档案) ===== */
.stu-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.stu-class-sel { flex: 0 0 220px; }
.stu-search { flex: 1 1 180px; }
.stu-summary {
    font-size: 13px;
    color: #6b7686;
    margin-bottom: 10px;
}
.stu-table-wrap {
    overflow-x: auto;
    border: 1px solid #e6eaf2;
    border-radius: 10px;
}
.stu-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    white-space: nowrap;
}
.stu-table th, .stu-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #eef1f7;
}
.stu-table th {
    background: #f4f6fb;
    color: #47536b;
    font-weight: 600;
    position: sticky;
    top: 0;
}
.stu-table tr:last-child td { border-bottom: none; }
.stu-table .mono { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }

/* ===== 运动会标准库 ===== */
.meetlib-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.meetlib-ver { font-size: 20px; font-weight: 700; }
.meetlib-sub { color: #6b7280; font-size: 13px; margin: 4px 0 0; }
.meetlib-actions { display: flex; gap: 8px; flex-shrink: 0; }
.meetlib-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; margin: 6px 0; }
.meetlib-h { margin: 18px 0 8px; font-size: 15px; }
.meetlib-list { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.8; }
.meetlib-publish { margin-top: 18px; padding-top: 4px; border-top: 1px solid #eef0f3; }
.meetlib-json { width: 100%; min-height: 260px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; box-sizing: border-box; }
.meetlib-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.meetlib-row .field-input { flex: 1; min-width: 200px; }
.meetlib-err { color: #d93025; font-size: 13px; margin-top: 6px; }
