/* ============================================================
   体测管理系统 · 响应式样式
   风格：浅色底 + 蓝色渐变主卡 + 白色圆角卡片 + 药丸标签
   断点：xs<480 / sm 480-767（手机）· md 768-991（平板）· lg>=992（电脑）· xl>=1440（宽屏）

   ⚠ 两条"防挤压"铁律（改样式前先看一眼）：
   1. .btn 永远 white-space:nowrap + flex:0 0 auto —— 否则在 flex 行里会被压成竖条（"查询"两个字上下叠）
   2. 窄屏下 .row.nowrap 必须允许换行，输入类控件给 min-width:0 —— 否则下拉框被裁成"全部班"
   ============================================================ */

:root {
    --bg: #f4f6fa;
    --card: #ffffff;
    --primary: #3d7dfa;
    --primary-d: #2f6ce8;
    --primary-l: #6aa8ff;
    --grad: linear-gradient(135deg, #4a86f7 0%, #6fb0ff 100%);
    --text: #1f2a3c;
    --text-2: #55617a;
    --muted: #93a0b5;
    --line: #e9edf5;
    --line-2: #dfe5f0;
    --ok: #1fbf75;
    --warn: #f5a623;
    --danger: #ef4b5b;
    --info: #4a86f7;
    --radius: 16px;
    --radius-s: 12px;
    --radius-l: 20px;
    --shadow: 0 2px 12px rgba(29, 47, 79, .06);
    --shadow-l: 0 8px 26px rgba(29, 47, 79, .10);
    --gap: 12px;
    --pad: 14px;
    --sidebar-w: 232px;
    --topbar-h: 58px;
    --bottomnav-h: 70px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; }
input, select, textarea, button { font-family: inherit; }

/* ---------------- 布局骨架 ---------------- */
.app-shell { display: flex; min-height: 100vh; align-items: flex-start; }

.sidebar {
    display: none;
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: #fff;
    border-right: 1px solid var(--line);
    padding: 16px 12px 24px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 14px; }
.brand .logo {
    width: 38px; height: 38px; border-radius: 12px; background: var(--grad);
    display: flex; align-items: center; justify-content: center; color: #fff;
    font-weight: 700; font-size: 17px; flex: 0 0 38px;
}
.brand .t1 { font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand .t2 { font-size: 11px; color: var(--muted); }

.nav-group { margin: 14px 0 6px; padding: 0 12px; font-size: 11px; color: var(--muted); letter-spacing: .5px; }
.nav-item {
    display: flex; align-items: center; gap: 10px; padding: 9px 12px;
    border-radius: 11px; color: var(--text-2); font-size: 14px; margin-bottom: 2px;
    transition: background .15s, color .15s;
}
.nav-item:hover { background: #f3f7ff; color: var(--primary); }
.nav-item.active { background: #eaf2ff; color: var(--primary); font-weight: 600; }
.nav-item .ic { width: 18px; text-align: center; font-size: 15px; flex: 0 0 18px; }

.main { flex: 1; min-width: 0; padding-bottom: calc(var(--bottomnav-h) + 24px + env(safe-area-inset-bottom, 0px)); }
.container { max-width: 1360px; margin: 0 auto; padding: var(--pad) var(--pad) 0; }

/* ---------------- 顶栏 ---------------- */
.topbar {
    display: flex; align-items: center; gap: 12px;
    padding: 12px var(--pad) 8px; max-width: 1360px; margin: 0 auto;
}
.topbar .who { flex: 1; min-width: 0; }
.topbar .h1 {
    font-size: 19px; font-weight: 700; line-height: 1.3;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar .h2 {
    font-size: 12px; color: var(--muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.avatar {
    width: 40px; height: 40px; border-radius: 50%; background: var(--grad);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 700; flex: 0 0 40px;
}

/* ---------------- 主卡（蓝色渐变） ---------------- */
.hero {
    background: var(--grad);
    border-radius: var(--radius-l);
    padding: 18px 18px 16px;
    color: #fff;
    box-shadow: 0 10px 24px rgba(74, 134, 247, .28);
    position: relative;
    overflow: hidden;
}
.hero::after {
    content: ""; position: absolute; right: -50px; top: -60px;
    width: 190px; height: 190px; border-radius: 50%;
    background: rgba(255, 255, 255, .12);
}
.hero > * { position: relative; z-index: 1; }
.hero .tag {
    display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
    background: rgba(255, 255, 255, .22); padding: 3px 10px; border-radius: 999px;
}
.hero .big { font-size: 34px; font-weight: 700; line-height: 1.15; margin-top: 6px; }
.hero .big small { font-size: 14px; font-weight: 500; opacity: .9; margin-left: 4px; }
.hero .sub { font-size: 12.5px; opacity: .92; }
.hero .bar { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .3); margin-top: 12px; overflow: hidden; }
.hero .bar > i { display: block; height: 100%; background: #fff; border-radius: 999px; transition: width .4s ease; }
.hero .cols { display: flex; gap: 26px; margin-top: 4px; flex-wrap: wrap; }
.hero .hero-main { min-width: 0; }
.hero .hero-foot {
    display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px;
    align-items: flex-end;
}

/* ---------------- 卡片 ---------------- */
.card {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: var(--pad); margin-bottom: var(--gap);
}
.card.tight { padding: 10px 12px; }
.card-h { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.card-h .dot { width: 4px; height: 15px; border-radius: 3px; background: var(--primary); flex: 0 0 4px; }
.card-h .tt { font-weight: 650; font-size: 15px; }
.card-h .more { margin-left: auto; font-size: 12.5px; color: var(--muted); white-space: nowrap; }

/* 桌面双栏：>=992 自动两列，窄屏自动回落单列 */
.split { display: grid; gap: var(--gap); align-items: start; }
@media (min-width: 992px) { .split { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1440px) { .split.wide { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.split > .card:last-child { margin-bottom: var(--gap); }

/* ---------------- 药丸标签 ---------------- */
.pills {
    display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px;
    -ms-overflow-style: none; scrollbar-width: none;
    scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
}
.pills::-webkit-scrollbar { display: none; }
.pill {
    flex: 0 0 auto; padding: 7px 15px; border-radius: 999px; font-size: 13px;
    background: #eef1f7; color: var(--text-2); white-space: nowrap; border: none;
    cursor: pointer; scroll-snap-align: start; transition: background .15s, color .15s;
}
.pill:hover { background: #e4e9f3; }
.pill.on { background: var(--primary); color: #fff; font-weight: 600; box-shadow: 0 4px 10px rgba(61, 125, 250, .3); }

/* ---------------- 统计块 ---------------- */
.grid { display: grid; gap: var(--gap); }
.g2, .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.tile {
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 13px; display: flex; align-items: center; gap: 11px; min-width: 0;
}
.tile .icon {
    width: 42px; height: 42px; border-radius: 13px; flex: 0 0 42px;
    display: flex; align-items: center; justify-content: center; font-size: 19px;
}
.tile .num { font-size: 21px; font-weight: 700; line-height: 1.1; }
.tile .lbl { font-size: 12px; color: var(--muted); }
.tile > div:last-child { min-width: 0; }
.i-blue { background: #e8f1ff; color: #3d7dfa; }
.i-green { background: #e5f8ef; color: #1fbf75; }
.i-orange { background: #fff2e0; color: #f5a623; }
.i-purple { background: #f0eaff; color: #7c5cff; }
.i-red { background: #ffe9ec; color: #ef4b5b; }

/* ---------------- 列表项 ---------------- */
.list { display: flex; flex-direction: column; min-width: 0; }
.item {
    display: flex; align-items: center; gap: 11px; padding: 11px 2px;
    border-bottom: 1px solid var(--line);
    min-width: 0;                 /* ★ 允许在窄容器里收缩，别把卡片顶宽 */
}
.item:last-child { border-bottom: none; }
.item .ic {
    width: 38px; height: 38px; border-radius: 12px; flex: 0 0 38px;
    display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.item .bd { flex: 1; min-width: 0; }
.item .t1 { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .t2 { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* ★ 右侧信息列原来是 flex:0 0 auto（**完全不可收缩**）——手机端系统字号/App 文本缩放一旦把字放大，
   这一列就会把整行顶得比卡片还宽，内容跑到屏幕外（"超出手机宽度、不会自动调整"）。
   改成可收缩 + 省略号：宁可把右列文字截短，也不让整行溢出。 */
.item .rt {
    text-align: right; flex: 0 1 auto; min-width: 0;
    overflow: hidden; text-overflow: ellipsis;
}
.item .rt > * { max-width: 100%; }

/* 带按钮组的列表项：窄屏把操作区整体落到下一行，正文不再被挤成"尹强…" */
.item.has-actions .rt {
    display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
    min-width: 0;
}
.item.has-actions .rt form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.item.has-actions .rt .fld { width: auto; min-width: 120px; max-width: 190px; padding: 6px 8px; font-size: 12.5px; }

@media (max-width: 767px) {
    /* 头像 + 正文留在同一行（正文占满剩余宽度），只把操作区整体落到下一行 */
    .item.has-actions { flex-wrap: wrap; row-gap: 8px; align-items: flex-start; }
    .item.has-actions .ic { margin-top: 2px; }
    .item.has-actions .t1, .item.has-actions .t2 { white-space: normal; }
    .item.has-actions .rt {
        flex: 1 1 100%; align-items: stretch; text-align: left;
        border-top: 1px dashed var(--line); padding-top: 10px;
    }
    .item.has-actions .rt form { justify-content: stretch; }
    .item.has-actions .rt .fld { flex: 1 1 110px; max-width: none; }
    .item.has-actions .rt .btn { flex: 1 1 auto; }
}

/* ---------------- 徽章 ---------------- */
.badge {
    display: inline-block; padding: 2px 9px; border-radius: 999px;
    font-size: 11.5px; font-weight: 600; white-space: nowrap; line-height: 1.7;
}
.b-ok { background: #e5f8ef; color: #12915a; }
.b-good { background: #e8f1ff; color: #2f6ce8; }
.b-pass { background: #fff2e0; color: #c07c10; }
.b-fail { background: #ffe9ec; color: #d6384a; }
.b-gray { background: #eef1f7; color: #7b8798; }
.b-err { background: #fdeaec; color: #c0293c; }
.b-warn { background: #fdf3e3; color: #a2600a; }

/* ---------------- 表格 ---------------- */
.tbl-wrap {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-s);
    background:
        linear-gradient(to right, #fff 30%, rgba(255,255,255,0)) left center / 24px 100% no-repeat,
        linear-gradient(to left, #fff 30%, rgba(255,255,255,0)) right center / 24px 100% no-repeat,
        radial-gradient(farthest-side at 0 50%, rgba(29,47,79,.10), transparent) left center / 14px 100% no-repeat,
        radial-gradient(farthest-side at 100% 50%, rgba(29,47,79,.10), transparent) right center / 14px 100% no-repeat;
    background-attachment: local, local, scroll, scroll;
}
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 520px; }
table.tbl th, table.tbl td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tbl th { background: #f7f9fd; color: var(--text-2); font-weight: 600; }
table.tbl tr:hover td { background: #fafcff; }
table.tbl.narrow { min-width: 0; }
table.tbl td .btn, table.tbl td form { display: inline-flex; vertical-align: middle; }

/* 口令强度条 */
.pw-meter { height: 6px; border-radius: 999px; background: var(--line); margin-top: 8px; overflow: hidden; }
.pw-meter > i { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--line); transition: width .2s, background .2s; }

/* ---------------- 分页器 ---------------- */
.pager {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
    gap: 6px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line);
}
.pager .pg {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 38px; height: 38px; padding: 0 10px;
    border-radius: 10px; background: #eef1f7; color: var(--text-2);
    font-size: 13.5px; font-weight: 600; white-space: nowrap;
    -webkit-tap-highlight-color: transparent; transition: background .15s, color .15s;
}
.pager .pg:hover { background: #e4e9f3; color: var(--primary); }
.pager .pg.on { background: var(--primary); color: #fff; box-shadow: 0 3px 8px rgba(61, 125, 250, .3); }
.pager .pg.nav { padding: 0 13px; }
.pager .pg.off { opacity: .4; cursor: not-allowed; }
.pager .pg.off:hover { background: #eef1f7; color: var(--text-2); }
.pager .pg.gap { background: transparent; min-width: 18px; padding: 0; color: var(--muted); cursor: default; }
.pager-info { font-size: 12.5px; color: var(--muted); margin-left: 6px; white-space: nowrap; }
.pager-info b { color: var(--text-2); }
.pager-jump { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; }
.pager-jump label { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.pager-jump .fld { width: 72px; min-width: 0; padding: 7px 9px; font-size: 13px; text-align: center; }

@media (max-width: 560px) {
    .pager { gap: 5px; }
    .pager .pg { min-width: 34px; height: 36px; padding: 0 8px; font-size: 13px; }
    .pager .pg.nav { padding: 0 10px; }
    /* 手机上页码与信息分行，避免挤成一团 */
    .pager-info { flex: 1 1 100%; text-align: center; margin: 4px 0 0; }
    .pager-jump { flex: 1 1 100%; justify-content: center; margin: 4px 0 0; }
}

/* ---------------- 冻结左侧两列（横向滑动时序号 + 姓名固定不动） ----------------
   场景：手机录入成绩要往右滑才能摸到成绩框，滑过去就"不知道这是谁了"。
   用法：<table class="tbl freeze-2">（第 1 列序号、第 2 列姓名）
   ⚠ 三个必须同时满足的点，少一个就不生效：
     ① 冻结列必须有**不透明底色**，否则滑动内容会从下面透出来；
     ② 第 1 列宽度必须**写死**（第 2 列靠 left:固定值 才能贴住它）；
     ③ 单元格所在的行**不能有 opacity**（会形成层叠上下文，sticky 会失效）→ 用 .row-off 灰化。
   ------------------------------------------------------------------- */
table.tbl.freeze-2 { border-collapse: separate; border-spacing: 0; }

table.tbl.freeze-2 th:nth-child(1),
table.tbl.freeze-2 td:nth-child(1) {
    position: sticky; left: 0; z-index: 2;
    width: 46px; min-width: 46px; max-width: 46px;
    padding-left: 6px; padding-right: 6px; text-align: center;
    background: #fff;
}

table.tbl.freeze-2 th:nth-child(2),
table.tbl.freeze-2 td:nth-child(2) {
    position: sticky; left: 46px; z-index: 2;
    min-width: 104px;
    background: #fff;
    /* 冻结区右缘只留一条**细分割线**表示边界。
       ⚠ 原来这里是一圈 box-shadow（10px 0 13px -8px），用户反馈"一条灰带很难看"。
         现在靠这条 1px 实线定边界：滑过去时照样分得清冻结区，
         而且不会在表格中间压出一条阴影。 */
    border-right: 1px solid #d8e0ee;
}

/* 表头两列要在 body 之上，否则竖向滚动时会被数据行盖住 */
table.tbl.freeze-2 thead th:nth-child(1),
table.tbl.freeze-2 thead th:nth-child(2) { background: #f7f9fd; z-index: 3; }

/* 悬停 / 不可用行的底色也要跟着冻结列一起变，否则会出现半截高亮 */
table.tbl.freeze-2 tbody tr:hover td:nth-child(1),
table.tbl.freeze-2 tbody tr:hover td:nth-child(2) { background: #fafcff; }
table.tbl.freeze-2 tbody tr.row-off td:nth-child(1),
table.tbl.freeze-2 tbody tr.row-off td:nth-child(2) { background: #fbfcfe; }
table.tbl.freeze-2 tr.row-off td { color: var(--muted); }

/* 冻结表自带列分隔线，把 .tbl-wrap 的两侧渐隐提示关掉，避免双重提示 */
.tbl-wrap:has(> table.tbl.freeze-2) { background: none; }

/* ---------------- 表格操作列（逐人保存） ----------------
   场景：数据采集页每行右侧一个「保存」，只提交这一条成绩。
   要求：① 按钮不被压成竖条（white-space:nowrap + flex:0 0 auto）
        ② 状态文字不把表格撑宽（限宽 + 省略号，完整文案放 title） */
table.tbl th.op-col, table.tbl td.op-col {
    width: 1%; white-space: nowrap;
}
/* ⚠ 不给 <td> 直接上 display:flex —— 那会让它脱离表格布局算法，列宽会算歪。
   改成内层容器做 flex。 */
td.op-col .op-cell {
    display: flex; align-items: center; gap: 8px; justify-content: flex-start;
}
td.op-col .row-save { flex: 0 0 auto; white-space: nowrap; }
@media (max-width: 479px) {
    td.op-col .op-cell { gap: 6px; }
}

/* ===== 轻量弹窗：结果 toast + 自定义确认框（2026-10-15）=====
   为什么不用原生 confirm/alert：本页会被校园门户**嵌在（可能 sandbox 的）iframe 里**，
   沙箱下原生对话框会被静默忽略 —— 点"确定"其实返回 undefined，删除不执行也毫无提示。
   所以提示与确认都改成页面内 DOM，固定定位，任何嵌入环境都可见。 */
.fit-toast {
    position: fixed; left: 50%; top: 14px; transform: translate(-50%, -16px);
    max-width: min(92vw, 460px); padding: 11px 16px; border-radius: 10px;
    background: #16233a; color: #fff; font-size: 13.5px; line-height: 1.45; text-align: center;
    box-shadow: 0 10px 28px rgba(15, 27, 45, .30);
    opacity: 0; pointer-events: none; z-index: 9999;
    transition: opacity .18s ease, transform .18s ease;
}
.fit-toast.show { opacity: 1; transform: translate(-50%, 0); }
.fit-toast.ok { background: #0f7a4a; }
.fit-toast.warn { background: #a2600a; }
.fit-toast.err { background: #b32b3c; }

.fit-modal {
    position: fixed; inset: 0; background: rgba(15, 23, 38, .45); z-index: 10000;
    display: flex; align-items: center; justify-content: center; padding: 18px;
}
.fit-modal-box {
    background: #fff; border-radius: 12px; padding: 18px 18px 14px;
    width: min(92vw, 400px); box-shadow: 0 18px 48px rgba(15, 27, 45, .32);
}
.fit-modal-msg { font-size: 14px; line-height: 1.65; color: #1f2a3d; }
.fit-modal-acts { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.fit-modal-acts .btn { min-width: 78px; }

/* -------------------------------------------------------------------
   手机端：冻结两列**尽量贴左、尽量窄** —— 右边是要录入成绩的地方。
   实测（390 视口、可视宽 342）：改前冻结区占 156px（46%），输入列只露 62px。
   改法：序号 40→26、姓名 92→62 且**左对齐**（原来居中留白白占宽度）、单元格内边距 12→8。
   ⚠ 第 2 列的 left 必须跟着第 1 列的宽度改，否则滑过去会错位。
   ------------------------------------------------------------------- */
@media (max-width: 479px) {
    table.tbl.freeze-2 th:nth-child(1),
    table.tbl.freeze-2 td:nth-child(1) {
        width: 26px; min-width: 26px; max-width: 26px;
        padding-left: 2px; padding-right: 2px; font-size: 11.5px;
    }
    table.tbl.freeze-2 th:nth-child(2),
    table.tbl.freeze-2 td:nth-child(2) {
        left: 26px;
        /* 按内容自适应：2 字名就窄、4 字名刚好放下（≈53px），
           只有超长名（少数民族姓名等）才放宽到 80px 外再省略号 —— 比写死宽度省地方，也不会切名字 */
        width: auto; min-width: 52px; max-width: 80px;
        padding-left: 5px; padding-right: 5px;
        text-align: left; font-size: 12.5px;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    /* 中间那几列（学号/性别/年级）也收紧一点，把宽度让给成绩输入列 */
    table.tbl.freeze-2 th, table.tbl.freeze-2 td { padding: 10px 8px; }
}

@media print {
    table.tbl.freeze-2 th:nth-child(1), table.tbl.freeze-2 td:nth-child(1),
    table.tbl.freeze-2 th:nth-child(2), table.tbl.freeze-2 td:nth-child(2) {
        position: static !important; box-shadow: none !important;
    }
}

/* ---------------- 表单 ---------------- */
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 5px; font-weight: 600; }
.fld {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px;
    background: #fbfcfe; font-size: 14px; color: var(--text); outline: none;
    font-family: inherit; min-width: 0; transition: border-color .15s, box-shadow .15s, background .15s;
}
.fld:focus { border-color: var(--primary-l); background: #fff; box-shadow: 0 0 0 3px rgba(61, 125, 250, .12); }
.fld:disabled, .fld[readonly] { background: #f4f6fa; color: var(--text-2); }
select.fld {
    appearance: none; -webkit-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #93a0b5 50%), linear-gradient(135deg, #93a0b5 50%, transparent 50%);
    background-position: calc(100% - 16px) calc(50% - 2px), calc(100% - 11px) calc(50% - 2px);
    background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px;
    text-overflow: ellipsis;
}

/* 表单网格：窄屏单列，>=560 两列，>=992 三列 */
.form-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .form-grid.c2, .form-grid.c3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 992px) { .form-grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.form-grid .form-row { margin-bottom: 0; }

/* 勾选项（不要把 .row 套在 label 上，否则复选框和文字会被拆到两行） */
.check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; }
.check input[type="checkbox"], .check input[type="radio"] { width: 17px; height: 17px; margin: 2px 0 0; flex: 0 0 17px; accent-color: var(--primary); }
.check > span { flex: 1; min-width: 0; }
.check .t1 { font-size: 13.5px; font-weight: 600; }
.check .t2 { font-size: 12px; color: var(--muted); display: block; }
.check.chip {
    padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px;
    background: #fbfcfe; align-items: center;
}
.check.chip input { margin-top: 0; }
.check.chip > span { font-size: 13.5px; }
.check.chip:has(input:checked) { border-color: var(--primary-l); background: #f2f7ff; }

/* ---------------- 按钮 ---------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 18px; border-radius: 11px; border: none; cursor: pointer;
    font-size: 14px; font-weight: 600; font-family: inherit; background: var(--primary); color: #fff;
    /* ⚠ 这两行是"按钮被压成竖条"的解药，别删 */
    white-space: nowrap; flex: 0 0 auto; min-height: 42px; line-height: 1.2;
    transition: background .15s, transform .06s, box-shadow .15s;
    -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--primary-d); }
.btn:active { transform: translateY(1px); }
.btn.block { width: 100%; flex: 1 1 auto; }
.btn.ghost { background: #eef1f7; color: var(--text-2); }
.btn.ghost:hover { background: #e4e9f3; }
.btn.sm { padding: 7px 13px; font-size: 13px; border-radius: 9px; min-height: 34px; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #d63b4b; }
/* 描边红：用于"删除类但同排还有别的按钮"的场合 —— 与实心按钮区分，降低误点代价 */
.btn.danger-line { background: #fff; color: var(--danger); border: 1px solid #f0b3ba; }
.btn.danger-line:hover { background: #fff5f6; }
.btn[disabled], .btn:disabled { opacity: .55; cursor: not-allowed; }

/* 按钮组：窄屏自动换成"整行按钮"，不再挤在一起 */
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions .spacer { flex: 1; }
.actions > form { display: inline-flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 479px) {
    .actions.grow > .btn, .actions.grow > form, .actions.grow > form > .btn { flex: 1 1 100%; width: 100%; }
}

/* 区块小标题 + 模块勾选网格（角色授权页） */
.sec-title { font-size: 12.5px; color: var(--text-2); font-weight: 600; margin: 4px 0 8px; }
.mod-group { margin-bottom: 12px; }
.mod-group-title { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.mod-chips { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
@media (max-width: 400px) { .mod-chips { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); } }

/* 筛选/搜索行：窄屏整行堆叠，控件不再被裁成"全部班" */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters > .fld, .filters > select.fld { flex: 1 1 150px; min-width: 0; }
.filters > .btn { flex: 0 0 auto; }
/* 年级 + 班级 联动两列（2026-10-17）：手机上这两项挤在同一行，给成绩表格省一行高度。
   年级只需放下「高一」三个字，固定窄；班级吃剩余宽度（长班名靠 select 自身省略）。 */
.filters > .pair { display: flex; gap: 10px; flex: 1 1 260px; min-width: 0; }
.filters > .pair > select.fld { flex: 1 1 0; min-width: 0; width: auto; }
.filters > .pair > select.fld.grade { flex: 0 0 92px; }
@media (max-width: 560px) {
    .filters { flex-direction: column; align-items: stretch; }
    .filters > .fld, .filters > select.fld, .filters > .btn { flex: 1 1 auto; width: 100%; }
    .filters > .pair { flex: 1 1 auto; width: 100%; }
}

/* ---------------- 底部导航（手机） ----------------
   ⚠ 这是手机端最主要的手指落点，尺寸别往小改：
   图标 23px / 文字 12.5px / 整条高度 70px（含 safe-area），点按目标远大于 44px 的最小值。 */
.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: rgba(255, 255, 255, .96);
    backdrop-filter: saturate(180%) blur(12px); -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-top: 1px solid var(--line);
    display: flex; justify-content: space-around; align-items: stretch;
    padding: 7px 6px calc(9px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -3px 16px rgba(29, 47, 79, .08);
}
.bottom-nav a {
    flex: 1 1 0; min-width: 0; min-height: 52px;
    text-align: center; color: var(--muted);
    font-size: 12.5px; font-weight: 500; line-height: 1.2;
    padding: 6px 2px 5px; border-radius: 12px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    -webkit-tap-highlight-color: transparent;
    transition: background .15s, color .15s;
}
.bottom-nav a .ic { display: block; font-size: 23px; line-height: 1.1; }
.bottom-nav a:active { background: #eef3fd; }
.bottom-nav a.active { color: var(--primary); font-weight: 700; }
.bottom-nav a.active .ic { transform: translateY(-1px); }

/* 极窄屏（<360）略微收一点，保证 5 个仍然排得下 */
@media (max-width: 359px) {
    .bottom-nav a { font-size: 11.5px; }
    .bottom-nav a .ic { font-size: 21px; }
}

/* ---------------- 提示 ---------------- */
.alert { padding: 11px 14px; border-radius: 12px; font-size: 13.5px; margin-bottom: 12px; line-height: 1.6; }
.alert.ok { background: #e5f8ef; color: #12915a; }
.alert.err { background: #ffe9ec; color: #d6384a; }
.alert.warn { background: #fff2e0; color: #a9760d; }
.alert.info { background: #e8f1ff; color: #2f6ce8; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.right { text-align: right; }
.mt0 { margin-top: 0; }
.mb8 { margin-bottom: 8px; }
.mb12 { margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.row.nowrap > .fld, .row.nowrap > select.fld, .row.nowrap > input { min-width: 0; flex: 1 1 auto; }
.row.nowrap > .btn { flex: 0 0 auto; }
.spacer { flex: 1; }

/* 窄屏兜底：任何 nowrap 行都允许换行，避免控件被压扁 */
@media (max-width: 767px) {
    .row.nowrap { flex-wrap: wrap; }
    .row.nowrap > .btn { flex: 1 1 auto; }
    .row.nowrap > .fld, .row.nowrap > select.fld, .row.nowrap > input { flex: 1 1 150px; }
}

/* ---------------- 登录页 ---------------- */
.login-body { background: #eef2f9; }
.lg-wrap { display: flex; min-height: 100vh; min-height: 100dvh; }

/* 左：品牌区（窄屏隐藏，只留表单） */
.lg-brand {
    display: none;
    flex: 0 0 46%; position: relative; overflow: hidden;
    background: linear-gradient(150deg, #2f6ce8 0%, #4a86f7 48%, #6fb0ff 100%);
    color: #fff; padding: 48px 44px;
}
.lg-brand::after {
    content: ""; position: absolute; right: -110px; bottom: -130px;
    width: 380px; height: 380px; border-radius: 50%; background: rgba(255, 255, 255, .10);
}
.lg-brand::before {
    content: ""; position: absolute; left: -80px; top: -90px;
    width: 260px; height: 260px; border-radius: 50%; background: rgba(255, 255, 255, .08);
}
.lg-brand-in { position: relative; z-index: 1; display: flex; flex-direction: column; height: 100%; justify-content: center; }
.lg-logo {
    width: 60px; height: 60px; border-radius: 18px; display: flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, .22); color: #fff; font-size: 27px; font-weight: 700;
    border: 1px solid rgba(255, 255, 255, .35);
}
.lg-logo.sm { width: 46px; height: 46px; border-radius: 14px; font-size: 21px; flex: 0 0 46px;
    background: var(--grad); border: none; box-shadow: 0 6px 14px rgba(74, 134, 247, .32); }
.lg-brand h1 { font-size: 30px; margin: 20px 0 6px; letter-spacing: 1px; }
.lg-school { font-size: 14px; opacity: .92; margin: 0; }

/* 右：表单区 */
.lg-main {
    flex: 1; min-width: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; padding: 24px 18px calc(24px + env(safe-area-inset-bottom, 0px));
}
.lg-card {
    width: 100%; max-width: 400px; background: #fff; border-radius: 22px;
    box-shadow: 0 12px 40px rgba(29, 47, 79, .10); padding: 28px 24px 22px;
}
.lg-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.lg-title { font-size: 20px; font-weight: 700; line-height: 1.2; }
.lg-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.lg-alert { display: flex; align-items: flex-start; gap: 9px; }
.lg-alert-ic {
    flex: 0 0 18px; width: 18px; height: 18px; border-radius: 50%; text-align: center;
    font-size: 12px; font-weight: 700; line-height: 18px; margin-top: 1px;
    background: currentColor; color: #fff;
}
.lg-alert.err .lg-alert-ic { color: #fff; background: #d6384a; }
.lg-alert.info .lg-alert-ic { color: #fff; background: #2f6ce8; }

.lg-fld { padding: 13px 14px; font-size: 15px; border-radius: 12px; background: #f7f9fd; }
.lg-fld:focus { background: #fff; }
.lg-card .form-row { margin-bottom: 14px; }
.lg-card label { font-size: 13px; }

.lg-pwd { position: relative; }
.lg-pwd .lg-fld { padding-right: 46px; }
.lg-eye {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    width: 38px; height: 38px; border: none; background: transparent; cursor: pointer;
    font-size: 16px; line-height: 1; border-radius: 9px; color: var(--muted);
}
.lg-eye:hover { background: #eef2fa; }

.lg-cap { display: flex; gap: 10px; align-items: stretch; }
.lg-cap .lg-fld { flex: 1 1 auto; min-width: 0; letter-spacing: 3px; }
.lg-cap-img {
    flex: 0 0 118px; padding: 0; border: 1px solid var(--line); border-radius: 12px;
    background: #eef3fd; cursor: pointer; overflow: hidden; display: flex; align-items: center;
    -webkit-tap-highlight-color: transparent;
}
.lg-cap-img:active { opacity: .8; }
.lg-hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

.lg-remember { margin: 2px 0 16px; font-size: 13.5px; }
.lg-submit { min-height: 48px; font-size: 16px; letter-spacing: 4px; border-radius: 12px; }
.lg-note {
    margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line);
    font-size: 12px; color: var(--muted); line-height: 1.7;
}
.lg-note b { color: var(--text-2); }
.lg-foot {
    margin-top: 18px; font-size: 12px; color: var(--muted);
    display: flex; gap: 7px; align-items: center; flex-wrap: wrap; justify-content: center;
    text-align: center;
}
.lg-dot { opacity: .6; }

@media (min-width: 992px) {
    .lg-brand { display: block; }
    .lg-main { padding: 40px; }
    .lg-card { max-width: 420px; padding: 32px 30px 26px; }
}
@media (max-width: 400px) {
    .lg-card { padding: 22px 18px 18px; border-radius: 18px; }
    .lg-cap-img { flex: 0 0 100px; }
}

/* 旧版登录页容器（保留兼容，别的地方可能还在用） */
.login-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 20px; background: linear-gradient(160deg, #eaf2ff 0%, #f4f6fa 45%, #eef4ff 100%);
}
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 22px; box-shadow: var(--shadow-l); padding: 26px 22px; }
.login-logo {
    width: 62px; height: 62px; border-radius: 19px; background: var(--grad); margin: 0 auto 14px;
    display: flex; align-items: center; justify-content: center; color: #fff; font-size: 27px; font-weight: 700;
}

/* ---------------- 模态框 ---------------- */
.modal-mask {
    position: fixed; inset: 0; background: rgba(21, 32, 52, .45); z-index: 100;
    display: none; align-items: center; justify-content: center; padding: 16px;
}
.modal-mask.on { display: flex; }
.modal {
    background: #fff; border-radius: 18px; width: 100%; max-width: 460px;
    max-height: 88vh; overflow-y: auto; padding: 18px;
}
.modal h4 { margin: 0 0 12px; font-size: 16px; }

/* ---------------- 开关 ---------------- */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: 0 0 46px; }
.switch input { display: none; }
.switch i { position: absolute; inset: 0; background: #d7dce6; border-radius: 999px; transition: .2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + i { background: var(--primary); }
.switch input:checked + i::after { transform: translateX(20px); }
.switch-row { display: flex; align-items: center; gap: 10px; }
.switch-row .txt { flex: 1; min-width: 0; }
.switch-row .txt .t1 { font-size: 13.5px; font-weight: 600; }
.switch-row .txt .t2 { font-size: 12px; color: var(--muted); }
.kv { display: flex; gap: 10px; font-size: 13.5px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--text-2); flex: 0 0 92px; }
.kv .v { flex: 1; min-width: 0; word-break: break-all; }
.mono { font-family: Consolas, Menlo, monospace; font-size: 12px; }

/* ============================================================
   平板 >=768
   ============================================================ */
@media (min-width: 768px) {
    :root { --pad: 20px; }
    .container { padding: 18px var(--pad) 0; }
    .topbar { padding: 14px var(--pad) 10px; }
    .card { padding: 18px; }
    .card.tight { padding: 14px 16px; }
    .hero { padding: 22px 24px; }
    .hero .big { font-size: 40px; }
    .item { padding: 13px 2px; }
    /* 平板起 3 个统计块就排满一行，避免第三个孤零零占一行 */
    .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ============================================================
   电脑 >=992
   ============================================================ */
@media (min-width: 992px) {
    .sidebar { display: block; }
    .main { padding-bottom: 32px; }
    .bottom-nav { display: none; }
    .topbar .h1 { font-size: 22px; }
    .hero .big { font-size: 44px; }
    .hero { padding: 24px 28px; }

    /* 桌面：统计块 3/4 列，卡片更透气 */
    .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .tile { padding: 15px 16px; }
    .tile .num { font-size: 23px; }

    /* 桌面：hero 左信息右按钮，两栏各占其位（不要用绝对定位，会跟右侧的"完成度 %"叠在一起） */
    .hero:has(.hero-foot) {
        display: flex; align-items: flex-end; gap: 28px; flex-wrap: wrap;
    }
    .hero:has(.hero-foot) .hero-main { flex: 1 1 420px; }
    .hero:has(.hero-foot) .hero-foot { flex: 0 0 auto; margin-top: 0; }
    .hero .cols { gap: 40px; }

    .filters > .fld, .filters > select.fld { flex: 0 1 240px; }
    .filters > .fld.grow, .filters > select.fld.grow { flex: 1 1 240px; }

    table.tbl { font-size: 14px; }
    table.tbl th, table.tbl td { padding: 11px 14px; }
}

/* 宽屏 >=1440：进一步放宽 */
@media (min-width: 1440px) {
    :root { --pad: 24px; --gap: 14px; }
    .hero .big { font-size: 48px; }
}

/* ---------------- 小屏微调 ---------------- */
@media (max-width: 479px) {
    :root { --pad: 12px; --gap: 10px; }
    .topbar .h1 { font-size: 18px; }
    .hero { padding: 16px 16px 14px; border-radius: 18px; }
    .hero .big { font-size: 30px; }
    .hero .cols { gap: 20px; }
    .tile { padding: 12px; }
    .tile .icon { width: 38px; height: 38px; flex: 0 0 38px; border-radius: 11px; font-size: 17px; }
    .tile .num { font-size: 19px; }
    .kv .k { flex: 0 0 74px; }
    .card { border-radius: 14px; }
    table.tbl { font-size: 13px; min-width: 480px; }
    table.tbl th, table.tbl td { padding: 9px 10px; }
}

/* 极窄屏（<360，如 iPhone SE 竖屏）才把统计块降成一列 */
@media (max-width: 359px) {
    .grid.g2, .grid.g3, .grid.g4 { grid-template-columns: 1fr; }
}

/* 按视口隐藏内容 */
@media (max-width: 767px) {
    .hide-sm { display: none !important; }
}
@media (max-width: 479px) {
    .hide-xs { display: none !important; }
}
@media (min-width: 992px) {
    .hide-lg { display: none !important; }
}

/* 打印（个人报告单 / 统计报表导出 PDF） */
@media print {
    .sidebar, .bottom-nav, .topbar .no-print, .no-print { display: none !important; }
    body, .app-shell, .main { background: #fff !important; }
    .container { max-width: none; padding: 0; }
    .card, .hero { box-shadow: none !important; border: 1px solid #ddd; break-inside: avoid; }
    .hero { background: #f0f5ff !important; color: #1f2a3c !important; }
    .hero .big, .hero .sub, .hero .tag { color: #1f2a3c !important; }
    .hero:has(.hero-foot) { display: block !important; }
    .tbl-wrap { overflow: visible !important; background: none !important; }
    table.tbl { min-width: 0 !important; }
    a[href]::after { content: ""; }
}

/* ---------------- 手机端横向溢出兜底（2026-10-14） ----------------
   背景：用户报告在校园门户 App 里"下面内容超出手机宽度、不会自动调整"。
   本机在 320–430px、以及"文字放大 1.5 倍"下都复现不出来（逐元素扫描无越界），
   怀疑是 WebView 的文本缩放/布局宽度差异。这里做**兜底**：
   宁可把个别过宽的块裁掉，也绝不让整个页面横向跑出屏幕 —— 手机端不该出现横向滚动条。
   ⚠ 表格不受影响：它们都在 .tbl-wrap（自带 overflow-x:auto）里，仍旧可以左右滑动。
   ⚠ 只在手机端生效（≥768px 的桌面端不动，那边双栏布局依赖完整宽度）。 */
@media (max-width: 767px) {
    html, body { max-width: 100%; overflow-x: hidden; }
    .main, .container, .topbar, .hero, .card, .row, .cols, .filters, .card-h { min-width: 0; }
    /* 兜底长串（URL / 身份证号 / 无空格长文本）不要顶宽容器 */
    .break-anywhere, .t2, .muted { overflow-wrap: anywhere; }
}

/* ---------------- 图表统计（服务端 SVG 扇状图） ----------------
   图与图例并排；窄屏自动堆叠。图例把名称、人数、占比排成三栏，数字右对齐便于扫读。 */
.chart-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }

/* ===== 详细图表分析（2026-10-15）：100% 堆叠条 + 横向图例 ===== */
.chart-legend.hz { flex-direction: row; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.stk-rows { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.stk-row { display: flex; align-items: center; gap: 10px; }
.stk-lb { flex: 0 0 88px; width: 88px; font-size: 12.5px; color: var(--muted); text-align: right;
          overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stk-bar { flex: 1 1 auto; min-width: 0; display: flex; height: 20px; border-radius: 5px; overflow: hidden; background: #eef2f9; }
.stk-seg { display: flex; align-items: center; justify-content: center; font-size: 11px; color: #fff;
           line-height: 1; overflow: hidden; white-space: nowrap; }
.stk-v { flex: 0 0 46px; width: 46px; font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 479px) {
    .stk-lb { flex: 0 0 62px; width: 62px; font-size: 12px; }
    .stk-v { flex: 0 0 38px; width: 38px; }
}
.chart-legend { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.chart-legend .lg-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.chart-legend .lg-dot { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 10px; }
.chart-legend .lg-name { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-legend .lg-val { margin-left: auto; flex: 0 0 auto; font-variant-numeric: tabular-nums; font-weight: 600; }
@media print {
    .chart-wrap svg { break-inside: avoid; }
}
