/* ========== 全局基础 ========== */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --primary: #c0392b;
    --primary-dark: #96281b;
    --blue: #1e5aa8;
    --bg: #f2f4f8;
    --card: #ffffff;
    --text: #222;
    --muted: #777;
    --line: #e2e6ec;
    --radius: 12px;
}
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 16px; }

/* ========== 学员端 ========== */
.m-page {
    max-width: 560px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--bg);
    padding-bottom: 40px;
}
.m-header {
    background: linear-gradient(135deg, var(--primary), #e06454);
    color: #fff;
    padding: 26px 20px 22px;
    text-align: center;
}
.m-header .school { font-size: 21px; font-weight: 700; letter-spacing: 1px; }
.m-header .class-name {
    margin-top: 8px; font-size: 14px; opacity: .92;
    background: rgba(255,255,255,.18); display: inline-block;
    padding: 3px 14px; border-radius: 20px;
}
.m-header h1 { margin-top: 12px; font-size: 19px; font-weight: 600; }
.m-header .tip { margin-top: 6px; font-size: 12.5px; opacity: .85; }

.m-card {
    background: var(--card);
    margin: 14px 12px 0;
    border-radius: var(--radius);
    padding: 18px 16px 6px;
    box-shadow: 0 2px 10px rgba(30, 60, 120, .06);
}
.m-card h2 {
    font-size: 15px; color: var(--primary); margin-bottom: 10px;
    padding-left: 10px; border-left: 4px solid var(--primary);
}
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 14.5px; font-weight: 600; margin-bottom: 7px; }
.field label .req { color: var(--primary); margin-right: 3px; }
.field label .auto { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.field input[type="text"],
.field input[type="tel"],
.field input[type="date"],
.field select,
.field textarea {
    width: 100%;
    border: 1.5px solid var(--line);
    border-radius: 9px;
    padding: 11px 12px;
    background: #fafbfc;
    outline: none;
    transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--primary); background: #fff;
}
.field textarea { resize: vertical; min-height: 64px; }
.field .err { display: none; color: var(--primary); font-size: 12.5px; margin-top: 4px; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--primary); }
.field.invalid .err { display: block; }

.gender-group { display: flex; gap: 12px; }
.gender-group label {
    flex: 1; text-align: center; border: 1.5px solid var(--line);
    border-radius: 9px; padding: 11px 0; font-weight: 600; cursor: pointer;
    background: #fafbfc; margin: 0; font-size: 16px;
}
.gender-group input { display: none; }
.gender-group input:checked + span { color: #fff; }
.gender-group label:has(input:checked) { background: var(--primary); border-color: var(--primary); color: #fff; }

.check-line { display: flex; align-items: center; gap: 7px; font-size: 13.5px; margin-top: 6px; color: var(--muted); }
.check-line input { width: 17px; height: 17px; }

/* 照片上传 */
.photo-grid { display: flex; flex-direction: column; gap: 12px; }
.photo-box { border: 1.5px dashed #c4ccd8; border-radius: 10px; padding: 10px; text-align: center; background: #fafbfc; }
.photo-box .pb-label { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.photo-box .pb-tip { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.photo-box img.preview { max-width: 100%; max-height: 230px; border-radius: 8px; display: none; margin: 0 auto 8px; }
.photo-box.has-img { border-style: solid; border-color: #9fb8d8; }
.photo-box.has-img img.preview { display: block; }
.photo-box .pb-actions { display: flex; gap: 8px; justify-content: center; }
.btn-cam {
    background: var(--blue); color: #fff; border: none; border-radius: 8px;
    padding: 8px 18px; font-size: 14px;
}
.btn-cam.secondary { background: #8a97a8; }
.photo-box input[type="file"] { display: none; }

.submit-bar { padding: 22px 14px 0; }
.btn-submit {
    width: 100%; border: none; border-radius: 12px; padding: 15px 0;
    background: linear-gradient(135deg, var(--primary), #e06454);
    color: #fff; font-size: 18px; font-weight: 700; letter-spacing: 4px;
    box-shadow: 0 4px 14px rgba(192, 57, 43, .3);
}
.btn-submit:active { transform: scale(.985); }
.submit-note { text-align: center; font-size: 12px; color: var(--muted); margin-top: 10px; }

/* 成功页 */
.success-box { text-align: center; padding: 60px 24px; display: none; }
.success-box .circle {
    width: 88px; height: 88px; border-radius: 50%; margin: 0 auto 22px;
    background: #2ecc71; display: flex; align-items: center; justify-content: center;
}
.success-box .circle::after {
    content: ""; width: 40px; height: 22px;
    border-left: 6px solid #fff; border-bottom: 6px solid #fff;
    transform: rotate(-45deg) translate(4px, -4px);
}
.success-box h2 { font-size: 24px; margin-bottom: 10px; }
.success-box p { color: var(--muted); font-size: 15px; }
.success-box .s-name { color: var(--primary); font-weight: 700; font-size: 18px; }
.btn-edit {
    border: 1.5px solid var(--primary); background: #fff; color: var(--primary);
    border-radius: 10px; padding: 11px 30px; font-size: 15px; font-weight: 600;
}
.btn-edit:active { transform: scale(.97); }

/* ========== 管理后台 ========== */
.admin-body { background: #eef1f6; }
.admin-top {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff; padding: 0 22px; height: 58px;
    display: flex; align-items: center; justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
    position: sticky; top: 0; z-index: 50;
}
.admin-top .logo { font-size: 18px; font-weight: 700; letter-spacing: 1px; }
.admin-top .right { font-size: 13.5px; display: flex; align-items: center; gap: 14px; }
.admin-top .right a { color: #fff; text-decoration: none; opacity: .85; }
.btn-logout { background: rgba(255,255,255,.2); border: none; color: #fff; padding: 6px 14px; border-radius: 6px; font-size: 13px; }

.admin-wrap { max-width: 1180px; margin: 0 auto; padding: 18px; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs button {
    border: 1.5px solid var(--line); background: #fff; border-radius: 9px;
    padding: 9px 20px; font-size: 14.5px; font-weight: 600; color: #555;
}
.tabs button.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.panel { display: none; }
.panel.active { display: block; }
.card {
    background: #fff; border-radius: 12px; padding: 20px 22px;
    box-shadow: 0 2px 10px rgba(30,60,120,.06); margin-bottom: 16px;
}
.card h3 { font-size: 16px; margin-bottom: 14px; color: #333; }

.stat-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.stat-box { flex: 1; min-width: 150px; background: #fff; border-radius: 12px; padding: 18px 20px; box-shadow: 0 2px 10px rgba(30,60,120,.06); }
.stat-box .num { font-size: 30px; font-weight: 700; color: var(--primary); }
.stat-box .lbl { font-size: 13px; color: var(--muted); }

/* QR 大屏 */
.qr-stage { text-align: center; }
.qr-stage #qrcode, .qr-stage #qrcodeAdmin { display: inline-block; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.qr-stage #qrcode img, .qr-stage #qrcode canvas,
.qr-stage #qrcodeAdmin img, .qr-stage #qrcodeAdmin canvas { display: block; }
.qr-stage .url-text { font-size: 22px; font-weight: 700; color: var(--blue); margin-top: 14px; letter-spacing: 1px; }
.qr-stage .qr-tip { color: var(--muted); margin-top: 10px; font-size: 14px; }
.qr-pair { display: flex; gap: 28px; justify-content: center; align-items: flex-start; flex-wrap: wrap; }
.qr-pair .qr-block { flex: 0 0 320px; max-width: 320px; }
.qr-block h3 { font-size: 18px; margin-bottom: 12px; color: #333; }
.qr-block .url-text { font-size: 14px; letter-spacing: 0; margin-top: 10px; word-break: break-all; }

/* 选项卡旁的「二维码」入口按钮 */
.tab-action {
    border: 1.5px dashed var(--primary); background: #fff; color: var(--primary);
    border-radius: 9px; padding: 9px 20px; font-size: 14.5px; font-weight: 600;
}
.tab-action:hover { background: #fdf1ef; }

/* 管理后台二维码弹窗 */
.modal.qr-admin-modal { max-width: 460px; }
.qr-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.qr-modal-head h3 { margin: 0; }
.qr-close {
    border: none; background: #eef1f6; color: #666; width: 34px; height: 34px;
    border-radius: 50%; font-size: 22px; line-height: 1;
}

/* 按钮 */
.btn {
    border: none; border-radius: 8px; padding: 9px 18px;
    font-size: 14px; font-weight: 600; background: var(--blue); color: #fff;
}
.btn.red { background: var(--primary); }
.btn.gray { background: #8a97a8; }
.btn.light { background: #eef1f6; color: #444; border: 1px solid var(--line); }
.btn.sm { padding: 5px 12px; font-size: 13px; }
.btn.danger { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.btn.danger.solid { background: var(--primary); color: #fff; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table.data {
    width: 100%; border-collapse: collapse; font-size: 14px; min-width: 760px;
}
table.data th, table.data td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; white-space: nowrap; }
table.data th { background: #f5f7fa; font-weight: 600; }
table.data td.wrap { white-space: normal; min-width: 160px; }
table.data tr:nth-child(even) td { background: #fafbfd; }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; flex-wrap: wrap; }
.toolbar input[type="search"] {
    border: 1.5px solid var(--line); border-radius: 8px; padding: 9px 14px; min-width: 240px;
}

/* 设置表单 */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 20px; }
.form-grid .fg { display: flex; flex-direction: column; }
.form-grid .fg.full { grid-column: 1 / -1; }
.form-grid label { font-size: 13.5px; font-weight: 600; margin-bottom: 6px; color: #444; }
.form-grid input, .form-grid select {
    border: 1.5px solid var(--line); border-radius: 8px; padding: 9px 12px; outline: none;
}
.form-grid input:focus { border-color: var(--primary); }

/* 弹窗 */
.modal-mask {
    display: none; position: fixed; inset: 0; background: rgba(20,30,50,.5);
    z-index: 100; align-items: flex-start; justify-content: center; padding: 30px 14px; overflow-y: auto;
}
.modal-mask.show { display: flex; }
.modal {
    background: #fff; border-radius: 14px; max-width: 640px; width: 100%;
    padding: 22px 22px 18px;
}
.modal h3 { margin-bottom: 16px; font-size: 17px; }
.modal .modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* 登录页 */
.login-mask {
    position: fixed; inset: 0; z-index: 200;
    background: linear-gradient(135deg, var(--primary-dark), #6e1d14);
    display: flex; align-items: center; justify-content: center;
}
.login-card {
    background: #fff; border-radius: 16px; padding: 34px 32px;
    width: 340px; box-shadow: 0 12px 40px rgba(0,0,0,.3);
}
.login-card .lc-logo { text-align: center; font-size: 19px; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.login-card .lc-sub { text-align: center; font-size: 13px; color: var(--muted); margin-bottom: 22px; }
.login-card .fg { margin-bottom: 16px; }
.login-card label { display: block; font-size: 14px; margin-bottom: 6px; font-weight: 600; }
.login-card input { width: 100%; border: 1.5px solid var(--line); border-radius: 9px; padding: 11px 13px; outline: none; }
.login-card input:focus { border-color: var(--primary); }
.login-card .btn { width: 100%; padding: 12px; font-size: 16px; }
.login-card .lc-err { color: var(--primary); font-size: 13px; min-height: 18px; margin-bottom: 8px; text-align: center; }

/* Toast */
.toast {
    position: fixed; left: 50%; bottom: 60px; transform: translateX(-50%);
    background: rgba(30,30,35,.92); color: #fff; padding: 11px 22px;
    border-radius: 10px; font-size: 14px; z-index: 500;
    opacity: 0; transition: opacity .25s; pointer-events: none; max-width: 86%;
}
.toast.show { opacity: 1; }

@media (max-width: 720px) {
    .form-grid { grid-template-columns: 1fr; }
    .admin-top { padding: 0 12px; height: 52px; }
    .admin-top .logo { font-size: 14px; max-width: 62%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .admin-top .right { gap: 8px; font-size: 12px; }
    .admin-wrap { padding: 10px; }
    .card { padding: 14px 12px; }
    .tabs { gap: 6px; }
    .tabs button { padding: 8px 12px; font-size: 13px; }
    .qr-pair { gap: 16px; flex-direction: column; align-items: center; }
    .qr-pair .qr-block { flex: 0 0 auto; max-width: 100%; }
    .qr-stage #qrcode, .qr-stage #qrcodeAdmin { padding: 12px; }
    .qr-stage #qrcode img, .qr-stage #qrcode canvas,
    .qr-stage #qrcodeAdmin img, .qr-stage #qrcodeAdmin canvas { width: min(72vw, 290px) !important; height: auto !important; }
    .qr-stage .qr-block .url-text { font-size: 12.5px; }
    .login-card { width: calc(100vw - 32px); max-width: 340px; padding: 28px 22px; }
    .toolbar input[type="search"] { min-width: 0; width: 100%; }
}
