/* =============================================================
   小分统计系统 · 样式
   与「阅卷学情分析管理后台」保持同一套视觉语言（蓝灰后台风）
   不依赖任何 CSS 框架 / CDN，便于在内网或宝塔环境稳定运行
   ============================================================= */

:root {
    --blue: #2563eb;
    --blue-dark: #1d4ed8;
    --blue-50: #eff6ff;
    --bg: #f3f4f6;
    --card: #ffffff;
    --border: #e5e7eb;
    --border-soft: #f0f1f3;
    --text: #111827;
    --text-2: #4b5563;
    --text-3: #9ca3af;
    --green: #16a34a;
    --red: #dc2626;
    --amber: #d97706;
    --teal: #0d9488;
    --orange: #ea580c;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-lg: 0 10px 30px rgba(16, 24, 40, .12), 0 2px 8px rgba(16, 24, 40, .06);
    --sidebar: 216px;
}

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

html, body { height: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 布局 ---------- */
#app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
    width: var(--sidebar);
    flex: 0 0 var(--sidebar);
    background: #fff;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 20;
}

.logo {
    padding: 18px 16px 14px;
    font-size: 16px;
    font-weight: 600;
    color: var(--blue);
    border-bottom: 1px solid var(--border);
    letter-spacing: .2px;
}
.logo small {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: var(--text-3);
    margin-top: 2px;
    letter-spacing: 0;
}

.nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    cursor: pointer;
    margin-bottom: 4px;
    transition: background .15s, color .15s;
    user-select: none;
}
.nav-item:hover { background: #f3f4f6; color: var(--text); }
.nav-item.on { background: var(--blue); color: #fff; }
.nav-item .ico { width: 18px; text-align: center; font-size: 15px; }

.side-foot {
    padding: 10px 14px 14px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-3);
    line-height: 1.6;
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100%; }

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.topbar h2 { font-size: 16px; font-weight: 600; }
.topbar .sub { font-size: 12px; color: var(--text-3); font-weight: 400; margin-left: 8px; }

.content { flex: 1; overflow-y: auto; padding: 18px 20px 40px; }

/* ---------- 卡片 ---------- */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 18px;
    margin-bottom: 16px;
}
.card.pad0 { padding: 0; overflow: hidden; }
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.card-head h3 { font-size: 15px; font-weight: 600; }
.card-head .hint { font-size: 12px; color: var(--text-3); font-weight: 400; }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

@media (max-width: 1180px) {
    .g4, .g5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
    .g2, .g3, .g4, .g5 { grid-template-columns: 1fr; }
    :root { --sidebar: 60px; }
    .nav-item span:not(.ico) { display: none; }
    .logo { font-size: 13px; padding: 14px 8px; }
    .logo small { display: none; }
    .side-foot { display: none; }
}

/* ---------- KPI ---------- */
.kpi {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 16px;
    border-left: 4px solid var(--blue);
}
.kpi.g { border-left-color: var(--green); }
.kpi.a { border-left-color: var(--amber); }
.kpi.r { border-left-color: var(--red); }
.kpi.t { border-left-color: var(--teal); }
.kpi .k { font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.kpi .v { font-size: 22px; font-weight: 600; line-height: 1.2; }
.kpi .v small { font-size: 12px; font-weight: 400; color: var(--text-3); margin-left: 2px; }
.kpi .f { font-size: 11px; color: var(--text-3); margin-top: 3px; }

/* ---------- 表单 ---------- */
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.mb { margin-bottom: 12px; }
.lab { font-size: 13px; color: var(--text-2); font-weight: 500; white-space: nowrap; }
.spacer { flex: 1; }

input[type=text], input[type=number], input[type=password], input[type=search], select, textarea {
    font-family: inherit;
    font-size: 13px;
    color: var(--text);
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    max-width: 100%;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
input[disabled] { background: #f9fafb; color: var(--text-3); }
input.w80 { width: 80px; }
input.w120 { width: 120px; }
input.w200 { width: 200px; }
input.w260 { width: 260px; }
textarea { resize: vertical; min-height: 60px; width: 100%; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
    font-size: 13px;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--blue);
    color: #fff;
    cursor: pointer;
    transition: background .15s, opacity .15s;
    white-space: nowrap;
    user-select: none;
}
.btn:hover { background: var(--blue-dark); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--text-2); border-color: #d1d5db; }
.btn.ghost:hover { background: #f9fafb; color: var(--text); }
.btn.green { background: var(--green); }
.btn.green:hover { background: #15803d; }
.btn.red { background: var(--red); }
.btn.red:hover { background: #b91c1c; }
.btn.amber { background: var(--amber); }
.btn.amber:hover { background: #b45309; }
.btn.sm { padding: 3px 9px; font-size: 12px; }
.btn.xs { padding: 2px 7px; font-size: 11px; border-radius: 6px; }
.btn.link {
    background: none; color: var(--blue); padding: 2px 4px;
}
.btn.link:hover { background: var(--blue-50); text-decoration: none; }
.btn.link.danger { color: var(--red); }
.btn.link.danger:hover { background: #fef2f2; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tab {
    padding: 8px 14px; font-size: 13px; color: var(--text-2); cursor: pointer;
    border-bottom: 2px solid transparent; margin-bottom: -1px; user-select: none;
    transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--text); }
.tab.on { color: var(--blue); border-bottom-color: var(--blue); font-weight: 500; }

/* ---------- 表格 ---------- */
.tbl-wrap { overflow: auto; max-width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.tbl-wrap.plain { border: none; border-radius: 0; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; white-space: nowrap; }
table.tbl th, table.tbl td {
    border-bottom: 1px solid var(--border-soft);
    border-right: 1px solid var(--border-soft);
    padding: 7px 10px;
    text-align: center;
    font-size: 13px;
}
table.tbl th:last-child, table.tbl td:last-child { border-right: none; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl th {
    background: #f9fafb;
    font-weight: 600;
    color: var(--text-2);
    font-size: 12px;
    position: sticky;
    top: 0;
    z-index: 2;
}
table.tbl th.sortable { cursor: pointer; user-select: none; }
table.tbl th.sortable:hover { background: #f3f4f6; color: var(--text); }
table.tbl th .si { font-size: 10px; color: var(--text-3); margin-left: 3px; }
table.tbl th .si.on { color: var(--blue); font-weight: 700; }
table.tbl tbody tr:hover td { background: #f9fafb; }
table.tbl td.l { text-align: left; }
table.tbl td.r { text-align: right; }
table.tbl td.b { font-weight: 600; }
table.tbl td.sec {
    background: #f9fafb; font-weight: 600; text-align: left; color: var(--text-2);
}
table.tbl.compact th, table.tbl.compact td { padding: 4px 6px; font-size: 12px; }
table.tbl .empty { color: var(--text-3); padding: 28px 10px; }

.tr-err td { background: #fef2f2 !important; color: #b91c1c; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 2px 2px; font-size: 13px; color: var(--text-2); }

/* ---------- 标签 / 徽章 ---------- */
.tag {
    display: inline-block; padding: 1px 8px; border-radius: 100px;
    font-size: 11px; line-height: 18px; white-space: nowrap;
}
.tag.b { background: #dbeafe; color: #1e40af; }
.tag.g { background: #dcfce7; color: #166534; }
.tag.a { background: #fef3c7; color: #92400e; }
.tag.r { background: #fee2e2; color: #991b1b; }
.tag.t { background: #ccfbf1; color: #115e59; }
.tag.n { background: #f3f4f6; color: #4b5563; }
.tag.o { background: #ffedd5; color: #9a3412; }

.miss { color: var(--red); font-weight: 500; }
.muted { color: var(--text-3); }
.ok { color: var(--green); }
.warn { color: var(--amber); }
.err { color: var(--red); }
.b { font-weight: 600; }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }

/* ---------- 热力格 ---------- */
.heat { font-variant-numeric: tabular-nums; font-weight: 500; }
.h5 { background: #dcfce7; color: #14532d; }
.h4 { background: #d1fae5; color: #065f46; }
.h3 { background: #fef9c3; color: #713f12; }
.h2 { background: #ffedd5; color: #7c2d12; }
.h1 { background: #fee2e2; color: #7f1d1d; }
.h0 { background: #f9fafb; color: #9ca3af; }

.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 11px; color: var(--text-2); align-items: center; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 3px; vertical-align: -2px; }

/* ---------- 图表 ---------- */
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; }
.chart-box.xs { height: 170px; }

.bar-mini { height: 6px; border-radius: 3px; background: #e5e7eb; overflow: hidden; min-width: 54px; }
.bar-mini i { display: block; height: 100%; border-radius: 3px; background: var(--blue); }

/* ---------- 模板 / 题目树 ---------- */
.sec-block {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    overflow: hidden;
    background: #fff;
}
.sec-head {
    display: flex; align-items: center; gap: 8px;
    background: #f9fafb; padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.sec-head .no { width: 62px; }
.sec-head .tt { flex: 1; min-width: 140px; }
.sec-head .sum { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.grp-block { border-bottom: 1px dashed var(--border); padding: 8px 10px; }
.grp-block:last-child { border-bottom: none; }
.grp-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.grp-head .no { width: 56px; }
.grp-head .tt { flex: 1; min-width: 140px; }

.qlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 6px; }
.qrow {
    display: flex; align-items: center; gap: 6px;
    background: #fff; border: 1px solid var(--border-soft);
    border-radius: 6px; padding: 4px 6px;
}
.qrow .qn { font-size: 11px; color: var(--text-3); min-width: 22px; text-align: right; font-variant-numeric: tabular-nums; }
.qrow .qt { flex: 1; min-width: 0; font-size: 12px; }
.qrow .qs { width: 56px; text-align: center; font-size: 12px; padding: 3px 4px; }
.qrow .qx { color: var(--text-3); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; }
.qrow .qx:hover { color: var(--red); }

/* 题目列表（录入用） */
.qtree { max-height: calc(100vh - 300px); overflow-y: auto; }
.qtree .sec-t {
    font-size: 12px; font-weight: 600; color: var(--text-2);
    padding: 7px 10px; background: #f9fafb;
    border-top: 1px solid var(--border);
    position: sticky; top: 0; z-index: 1;
}
.qtree .grp-t {
    font-size: 11px; color: var(--text-3); padding: 5px 10px 3px 16px;
}
.qitem {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 6px 10px 6px 22px; font-size: 12px; cursor: pointer;
    border-left: 3px solid transparent;
}
.qitem:hover { background: #f9fafb; }
.qitem.on { background: var(--blue-50); border-left-color: var(--blue); color: var(--blue); font-weight: 500; }
.qitem .pct { font-size: 10px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.qitem.on .pct { color: var(--blue); }

/* ---------- 录入格子 ---------- */
.score-in {
    width: 62px; text-align: center; padding: 5px 4px; font-size: 13px;
    font-variant-numeric: tabular-nums; border: 1px solid #d1d5db;
    border-radius: 6px; outline: none; background: #fff;
}
.score-in:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.14); }
.score-in.dirty { background: #fffbeb; border-color: #fcd34d; }
.score-in.saved { background: #f0fdf4; border-color: #86efac; }
.score-in.bad { background: #fef2f2; border-color: #fca5a5; }
.score-in.absent { background: #f3f4f6; color: var(--text-3); }

.abs-btn {
    font-size: 11px; padding: 2px 7px; border-radius: 6px;
    border: 1px solid #d1d5db; background: #fff; color: var(--text-3);
    cursor: pointer; white-space: nowrap;
}
.abs-btn.on { background: #fef3c7; border-color: #fcd34d; color: #92400e; }

/* ---------- 弹窗 ---------- */
.mask {
    position: fixed; inset: 0; background: rgba(17, 24, 39, .45);
    display: flex; align-items: center; justify-content: center;
    z-index: 999; padding: 20px;
}
.modal {
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg);
    width: 100%; max-width: 720px; max-height: 88vh; display: flex; flex-direction: column;
    animation: pop .16s ease;
}
.modal.wide { max-width: 1000px; }
.modal.narrow { max-width: 460px; }
@keyframes pop { from { transform: scale(.97); opacity: 0 } to { transform: scale(1); opacity: 1 } }
.modal-head {
    padding: 14px 18px; border-bottom: 1px solid var(--border);
    font-size: 15px; font-weight: 600; display: flex; align-items: center; justify-content: space-between;
}
.modal-body { padding: 16px 18px; overflow-y: auto; flex: 1; }
.modal-foot {
    padding: 12px 18px; border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 8px; align-items: center;
}
.modal-foot .spacer { flex: 1; }
.x-close { cursor: pointer; color: var(--text-3); font-size: 20px; line-height: 1; padding: 0 4px; }
.x-close:hover { color: var(--text); }

/* ---------- 提示 ---------- */
.toast-wrap { position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
    background: rgba(17, 24, 39, .92); color: #fff; font-size: 13px;
    padding: 9px 16px; border-radius: 8px; max-width: 78vw;
    box-shadow: var(--shadow-lg); animation: pop .15s ease; white-space: pre-wrap;
}
.toast.ok { background: rgba(21, 128, 61, .95); }
.toast.err { background: rgba(185, 28, 28, .95); }

.notice {
    border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px;
    background: var(--blue-50); color: #1e40af; border: 1px solid #bfdbfe;
    margin-bottom: 14px; line-height: 1.7;
}
.notice.warn { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.notice.err { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.notice.g { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }

.empty-box { text-align: center; color: var(--text-3); padding: 46px 16px; font-size: 13px; }
.empty-box .big { font-size: 30px; margin-bottom: 10px; opacity: .5; }

/* ---------- 登录 ---------- */
.login-wrap {
    flex: 1;
    width: 100%;
    height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(150deg, #eef2ff 0%, #f3f4f6 45%, #ecfeff 100%);
    padding: 20px;
}
.login-card {
    background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg);
    padding: 34px 32px; width: 100%; max-width: 384px;
}
.login-card h1 { font-size: 19px; font-weight: 600; letter-spacing: .3px; margin-bottom: 4px; }
.login-card p.desc { font-size: 12px; color: var(--text-3); margin-bottom: 24px; line-height: 1.6; }
.login-card input { width: 100%; padding: 9px 12px; font-size: 14px; }
.login-card .btn { width: 100%; justify-content: center; padding: 9px; font-size: 14px; margin-top: 14px; }

/* ---------- 其它 ---------- */
.split { display: grid; grid-template-columns: 330px 1fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }

.sticky-side { position: sticky; top: 0; }

.badge-line { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.bar-inline { display: flex; align-items: center; gap: 8px; }
.bar-inline .bar-mini { flex: 1; }

.hl { background: #fef9c3; padding: 0 3px; border-radius: 3px; }

.rank-1 { color: #b45309; font-weight: 700; }
.rank-2 { color: #6b7280; font-weight: 600; }
.rank-3 { color: #a16207; font-weight: 600; }
