/* =====================================================================
   新芮运动会报名编排统计系统 —— 全局样式
   现代化 / 响应式 / 打印友好
   版本: v1.0 (修改本文件请同步升级模板中的 ?v= 参数)
   ===================================================================== */

:root {
    --primary: #1e6fd9;
    --primary-dark: #1554a8;
    --primary-light: #e8f1fd;
    --success: #18a058;
    --warning: #f0a020;
    --danger: #e0434c;
    --text: #1f2937;
    --text-sub: #6b7280;
    --border: #e5e7eb;
    --bg: #f4f6f9;
    --card: #ffffff;
    --radius: 12px;
    --shadow: 0 2px 10px rgba(16, 42, 80, .08);
    --shadow-lg: 0 8px 28px rgba(16, 42, 80, .14);
    --nav-w: 216px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 14px; color: var(--text); background: var(--bg);
    -webkit-text-size-adjust: 100%;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; border: 0; }

/* ---------------- 布局 ---------------- */
.app-header {
    position: sticky; top: 0; z-index: 60;
    background: linear-gradient(120deg, var(--primary) 0%, #2b8fff 100%);
    color: #fff; box-shadow: var(--shadow);
}
.app-header .hd-inner {
    max-width: 1500px; margin: 0 auto; padding: 10px 16px;
    display: flex; align-items: center; gap: 14px;
}
.app-header .logo { display: flex; align-items: center; gap: 10px; min-width: 0; }
.app-header .logo .mark {
    width: 36px; height: 36px; border-radius: 10px; flex: 0 0 36px;
    background: rgba(255,255,255,.22); display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 18px;
}
.app-header .logo .txt { min-width: 0; }
.app-header .logo .t1 { font-size: 16px; font-weight: 700; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-header .logo .t2 { font-size: 12px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-header .spacer { flex: 1; }
.app-header .hd-user { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.app-header .hd-user .avatar {
    width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,.25);
    display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.app-header a { color: #fff; }
.btn-link { background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.35); color: #fff;
    padding: 5px 12px; border-radius: 8px; font-size: 13px; cursor: pointer; }
.btn-link:hover { background: rgba(255,255,255,.3); text-decoration: none; }

.app-body { max-width: 1500px; margin: 0 auto; padding: 16px; display: flex; gap: 16px; align-items: flex-start; }
.app-side { width: var(--nav-w); flex: 0 0 var(--nav-w); position: sticky; top: 68px; }
.app-main { flex: 1; min-width: 0; }

/* ---------------- 侧栏导航 ---------------- */
.side-nav { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px; }
.side-nav .grp-title { font-size: 12px; color: var(--text-sub); padding: 10px 12px 4px; font-weight: 700; }
.side-nav a {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 12px; border-radius: 9px; color: var(--text); font-size: 14px; margin-bottom: 2px;
}
.side-nav a:hover { background: var(--primary-light); text-decoration: none; }
.side-nav a.on { background: var(--primary); color: #fff; font-weight: 600; }
.side-nav a .ic { width: 20px; text-align: center; opacity: .9; }

/* ---------------- 移动端底部导航 ---------------- */
.mobile-tabs {
    display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
    background: #fff; border-top: 1px solid var(--border); box-shadow: 0 -2px 12px rgba(0,0,0,.06);
    overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.mobile-tabs .tb { display: flex; min-width: 100%; }
.mobile-tabs a {
    flex: 1 0 auto; min-width: 72px; text-align: center; padding: 8px 6px; font-size: 12px; color: var(--text-sub);
}
.mobile-tabs a.on { color: var(--primary); font-weight: 700; }
.mobile-tabs a .ic { display: block; font-size: 18px; margin-bottom: 2px; }

/* ---------------- 卡片 / 区块 ---------------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; }
.card > .hd {
    padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 15px;
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.card > .hd .sub { font-weight: 400; font-size: 12px; color: var(--text-sub); }
.card > .bd { padding: 14px 16px; }
.card > .bd.flush { padding: 0; }
.spacer { flex: 1; }

/* ---------------- 统计块 ---------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat {
    background: linear-gradient(135deg, #fff 0%, #f7faff 100%);
    border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; text-align: center;
}
.stat .n { font-size: 26px; font-weight: 800; color: var(--primary); line-height: 1.2; }
.stat .l { font-size: 12px; color: var(--text-sub); margin-top: 4px; }
.stat.ok .n { color: var(--success); }
.stat.warn .n { color: var(--warning); }
.stat.err .n { color: var(--danger); }

/* ---------------- 按钮 ---------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    padding: 7px 14px; border: 1px solid var(--border); background: #fff; color: var(--text);
    border-radius: 8px; cursor: pointer; font-size: 13px; line-height: 1.4; white-space: nowrap;
    transition: all .15s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); color: #fff; }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.success:hover { opacity: .9; color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { opacity: .9; color: #fff; }
.btn.warn { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.lg { padding: 10px 22px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- 表单 ---------------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.fld { display: flex; flex-direction: column; gap: 4px; }
.fld > label { font-size: 12px; color: var(--text-sub); font-weight: 600; }
.fld .hint { font-size: 11px; color: #9ca3af; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=datetime-local],
input[type=tel], input[type=email], select, textarea {
    width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
    min-height: 38px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,111,217,.12); }
textarea { min-height: 90px; resize: vertical; }
label.cb { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--primary); }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.inline-form .fld { min-width: 130px; }

/* ---------------- 可搜索下拉(单位选择) ---------------- */
.combo { position: relative; }
.combo-list {
    position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px; z-index: 40;
    background: #fff; border: 1px solid var(--border); border-radius: 8px;
    box-shadow: var(--shadow-lg); max-height: 240px; overflow: auto;
}
.combo-list .it { padding: 8px 12px; cursor: pointer; font-size: 13px; border-bottom: 1px solid #f3f4f6; }
.combo-list .it:last-child { border-bottom: 0; }
.combo-list .it:hover { background: var(--primary-light); }
.combo-list .it .sub { color: var(--text-sub); font-size: 12px; margin-top: 2px; }
.combo-empty { padding: 10px 12px; color: var(--text-sub); font-size: 12px; }
.pick {
    display: inline-flex; align-items: center; gap: 6px; margin-top: 6px;
    padding: 5px 10px; background: var(--primary-light); color: var(--primary);
    border-radius: 8px; font-size: 13px;
}
.pick .x { cursor: pointer; font-weight: 700; padding: 0 2px; }
.school-search { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }

/* ---------------- 表格 ---------------- */
.tw { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tb { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 520px; }
table.tb th, table.tb td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
table.tb th { background: #f8fafc; font-weight: 700; color: var(--text-sub); white-space: nowrap; position: sticky; top: 0; }
table.tb tbody tr:hover { background: #f9fbff; }
table.tb td.c, table.tb th.c { text-align: center; }
table.tb .act { white-space: nowrap; }
table.tb input[type=text] { min-height: 30px; padding: 4px 6px; font-size: 13px; }
.tb-empty { padding: 28px; text-align: center; color: var(--text-sub); }

/* ---------------- 徽标 ---------------- */
.tag { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; background: var(--primary-light); color: var(--primary); }
.tag.ok { background: #e7f7ee; color: var(--success); }
.tag.warn { background: #fdf3e3; color: var(--warning); }
.tag.err { background: #fdeaea; color: var(--danger); }
.tag.gray { background: #f1f2f4; color: var(--text-sub); }

/* ---------------- 提示 / 弹窗 ---------------- */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; border: 1px solid transparent; }
.alert.ok { background: #e7f7ee; color: #137a45; border-color: #b7e6cd; }
.alert.err { background: #fdeaea; color: #b3262e; border-color: #f6c9cc; }
.alert.warn { background: #fdf3e3; color: #92610b; border-color: #f5dfae; }
.alert.info { background: var(--primary-light); color: var(--primary-dark); border-color: #c3ddfa; }

.mask { position: fixed; inset: 0; background: rgba(15,25,40,.5); z-index: 100; display: none; align-items: center; justify-content: center; padding: 16px; }
.mask.on { display: flex; }
.modal { background: #fff; border-radius: var(--radius); width: 100%; max-width: 640px; max-height: 88vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.modal .mh { padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 700; display: flex; align-items: center; }
.modal .mb { padding: 16px; overflow: auto; }
.modal .mf { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.modal .close { cursor: pointer; color: var(--text-sub); font-size: 20px; line-height: 1; }

#toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column-reverse; gap: 8px; align-items: center; pointer-events: none; }
#toast .t { background: rgba(25,35,50,.92); color: #fff; padding: 9px 18px; border-radius: 20px; font-size: 13px; box-shadow: var(--shadow-lg); animation: fadeIn .2s; }
#toast .t.ok { background: rgba(24,160,88,.95); }
#toast .t.err { background: rgba(224,67,76,.95); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

/* ---------------- 首页 ---------------- */
.hero {
    background: linear-gradient(120deg, #1e6fd9 0%, #35a3ff 60%, #52c7ff 100%);
    color: #fff; border-radius: 16px; padding: 26px 22px; margin-bottom: 16px; box-shadow: var(--shadow-lg);
}
.hero h1 { margin: 0 0 6px; font-size: 24px; font-weight: 800; }
.hero p { margin: 4px 0; opacity: .92; font-size: 13px; }
.hero .btns { margin-top: 14px; display: flex; gap: 10px; flex-wrap: wrap; }
.hero .btn { background: #fff; color: var(--primary); border-color: #fff; font-weight: 600; }
.hero .btn.ghost { background: rgba(255,255,255,.16); color: #fff; border-color: rgba(255,255,255,.5); }

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.feature { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; transition: .2s; }
.feature:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: #c3ddfa; }
.feature .fi { font-size: 24px; margin-bottom: 6px; }
.feature h4 { margin: 0 0 4px; font-size: 15px; }
.feature p { margin: 0; font-size: 12px; color: var(--text-sub); line-height: 1.6; }

.steps { counter-reset: s; }
.steps .step { position: relative; padding: 8px 0 8px 34px; border-bottom: 1px dashed var(--border); font-size: 13px; line-height: 1.7; }
.steps .step:before {
    counter-increment: s; content: counter(s);
    position: absolute; left: 0; top: 8px; width: 22px; height: 22px; border-radius: 50%;
    background: var(--primary); color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.steps .step:last-child { border-bottom: 0; }

/* ---------------- 登录 ---------------- */
.login-wrap { max-width: 380px; margin: 40px auto; }
.login-card { background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); padding: 28px; }
.login-card h2 { margin: 0 0 4px; font-size: 20px; text-align: center; }
.login-card .sub { text-align: center; color: var(--text-sub); font-size: 12px; margin-bottom: 18px; }

/* ---------------- 参赛证 / 打印 ---------------- */
.badges { display: flex; flex-wrap: wrap; gap: 12px; }
.badge {
    width: 240px; border: 1px solid #c9d6e6; border-radius: 10px; padding: 10px; background: #fff;
    display: flex; gap: 10px; page-break-inside: avoid;
}
.badge .ph { width: 76px; height: 100px; border: 1px solid #dfe6ee; border-radius: 6px; object-fit: cover; background: #f5f7fa; }
.badge .info { flex: 1; font-size: 12px; line-height: 1.7; }
.badge .info .nm { font-size: 16px; font-weight: 800; }
.badge .info .no { color: var(--primary); font-weight: 700; }

/* 参赛证预览版式: 与打印一致(名称置顶, 照片+信息在下), 寸照适当增大 */
.badge-area .badge { width: 300px; flex-direction: column; }
.badge-area .bh {
    font-size: 14px; font-weight: 800; text-align: center; color: var(--primary);
    border-bottom: 1px solid #e3eaf3; padding-bottom: 4px; margin-bottom: 6px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.badge-area .bc { display: flex; gap: 10px; align-items: center; }
.badge-area .badge .ph { width: 90px; height: 120px; }
.badge-area .badge .info { font-size: 12px; line-height: 1.6; }

/* 无照片占位: 灰色人形图标, 与寸照 38x50 尺寸一致 */
.ph-empty {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 50px; border-radius: 4px; background-color: #eef1f5;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23b6bfca'%3E%3Cpath d='M12 12a5 5 0 1 0-5-5 5 5 0 0 0 5 5zm0 2c-4 0-8 2-8 5v1h16v-1c0-3-4-5-8-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: center; background-size: 22px 22px;
    vertical-align: middle;
}

.print-title { display: none; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 12px; flex-wrap: wrap; }
.pg-btn { padding: 5px 12px; border: 1px solid var(--border); background: #fff; border-radius: 8px; cursor: pointer; font-size: 13px; }
.pg-btn:hover { border-color: var(--primary); color: var(--primary); }
.pg-info { font-size: 12px; color: var(--text-sub); }

/* ---------------- 页脚 ---------------- */
.app-footer { max-width: 1500px; margin: 0 auto; padding: 18px 16px 30px; color: var(--text-sub); font-size: 12px; text-align: center; line-height: 1.8; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 900px) {
    .app-body { padding: 12px; flex-direction: column; }
    .app-side { display: none; width: 100%; flex: none; position: static; }
    .app-side.show { display: block; }
    .app-main { width: 100%; }
    .mobile-tabs { display: block; }
    body { padding-bottom: 58px; }
    .hero h1 { font-size: 20px; }
    .card > .hd { padding: 10px 12px; font-size: 14px; }
    .card > .bd { padding: 12px; }
    table.tb { font-size: 12px; }
    .stat .n { font-size: 22px; }
    .modal { max-height: 92vh; }
}
@media (max-width: 480px) {
    .app-header .logo .t2 { display: none; }
    .form-grid { grid-template-columns: 1fr; }
    .btn { padding: 7px 10px; font-size: 12px; }
}

/* ---------------- 打印 ---------------- */
@page { size: A4; margin: 3mm; }
@media print {
    body { background: #fff; padding: 0; }
    .app-header, .app-side, .mobile-tabs, .app-footer, .no-print, .pager { display: none !important; }
    .app-body { display: block; padding: 0; max-width: none; }
    .card { box-shadow: none; border: 0; margin: 0; page-break-inside: avoid; }
    .card > .hd { padding: 6px 0; }
    /* 打印时隐藏卡片头部的操作按钮与筛选控件(复制/打印/筛选等) */
    .card > .hd .btn, .card > .hd select, .card > .hd input { display: none !important; }
    .card > .bd { padding: 0; }
    table.tb th, table.tb td { padding: 4px 6px; border: 1px solid #999; }
    .print-title { display: none; }
    /* 参赛证: A4(210x297), 页边距 3mm, 每行 2 张, 每页 10 张(5 行)
       列间距 6mm/行间距 6mm, 单张 ≈ 99mm×53mm, 可用面积最大化 */
    .badge-area { page-break-inside: auto; }
    .badge-area .badges {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        column-gap: 6mm;
        row-gap: 6mm;
        align-content: start;
    }
    .badge-area .badge {
        width: auto; height: 53mm; margin: 0; padding: 2.5mm 3mm;
        box-sizing: border-box; display: flex; flex-direction: column;
        border: 1px solid #c9d6e6; border-radius: 6px; overflow: hidden;
        break-inside: avoid; page-break-inside: avoid;
    }
    .badge-area .bh {
        font-size: 11pt; font-weight: 800; text-align: center; color: var(--primary);
        border-bottom: 1px solid #e3eaf3; padding-bottom: 1.5mm; margin-bottom: 2mm;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .badge-area .bc { display: flex; gap: 3mm; align-items: center; flex: 1; min-height: 0; }
    .badge-area .badge .ph { width: 25mm; height: 33mm; border-radius: 3px; flex: none; }
    .badge-area .badge .info { font-size: 10.5pt; line-height: 1.45; flex: 1; min-width: 0; }
    .badge-area .badge .info .nm { font-size: 14pt; font-weight: 800; margin-bottom: 1mm; }
    .badge-area .badge .info .no { font-size: 11.5pt; color: var(--primary); font-weight: 700; }
}
