/* ============================================================
   企业培训答题系统 v2 - 全站样式（考试端 + 后台）
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --brand: #2563eb;
    --brand-dark: #1e40af;
    --brand-light: #eff6ff;
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --warning: #d97706;
    --warning-bg: #fffbeb;
    --ink: #0f172a;
    --ink-2: #334155;
    --ink-3: #64748b;
    --line: #e2e8f0;
    --bg: #f1f5f9;
    --card: #ffffff;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.06);
    --shadow-lg: 0 8px 30px rgba(15,23,42,.12);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.container { max-width: 780px; margin: 0 auto; padding: 28px 18px 60px; }
.container-wide { max-width: 1180px; margin: 0 auto; padding: 28px 22px 60px; }

/* ---------- 顶部品牌栏 ---------- */
.topbar {
    background: linear-gradient(135deg, var(--brand-dark), var(--brand));
    color: #fff;
    padding: 0 22px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 2px 12px rgba(30,64,175,.28);
}
.topbar .brand { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.topbar .brand svg { width: 22px; height: 22px; }
.topbar .who { font-size: 13px; opacity: .92; display: flex; align-items: center; gap: 14px; }
.topbar .who a { color: #fff; text-decoration: underline; opacity: .85; }

/* ---------- 卡片 ---------- */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 26px;
    margin-bottom: 18px;
}
.card-title { font-size: 17px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card-title::before { content: ''; width: 4px; height: 16px; border-radius: 2px; background: var(--brand); }

/* ---------- 说明页（考试前） ---------- */
.hero {
    background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand) 55%, #3b82f6 100%);
    color: #fff;
    border-radius: 20px;
    padding: 44px 30px 38px;
    text-align: center;
    margin-bottom: 22px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}
.hero::after {
    content: '';
    position: absolute; inset: 0;
    background: radial-gradient(circle at 82% 18%, rgba(255,255,255,.16), transparent 46%);
    pointer-events: none;
}
.hero h1 { font-size: 26px; font-weight: 800; letter-spacing: .5px; }
.hero p { margin-top: 10px; opacity: .88; font-size: 14px; }

.rules { list-style: none; margin: 8px 0 20px; }
.rules li {
    padding: 11px 14px; margin-bottom: 9px;
    background: var(--bg); border-radius: 10px;
    font-size: 14px; color: var(--ink-2);
    display: flex; gap: 10px; align-items: flex-start;
}
.rules li .ico { color: var(--brand); font-weight: 700; flex-shrink: 0; }

/* ---------- 表单控件 ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.input, .select, .textarea {
    width: 100%; padding: 11px 14px;
    border: 1.5px solid var(--line); border-radius: 10px;
    font-size: 14.5px; color: var(--ink); background: #fff;
    transition: border-color .18s, box-shadow .18s;
    font-family: inherit;
}
.input:focus, .select:focus, .textarea:focus {
    outline: none; border-color: var(--brand);
    box-shadow: 0 0 0 3.5px rgba(37,99,235,.13);
}
.textarea { resize: vertical; min-height: 74px; }
.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 11px 22px; border: none; border-radius: 10px;
    font-size: 14.5px; font-weight: 600; cursor: pointer;
    transition: all .18s; font-family: inherit; text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(37,99,235,.35); }
.btn-ghost { background: #fff; color: var(--ink-2); border: 1.5px solid var(--line); }
.btn-ghost:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #15803d; }
.btn-lg { padding: 15px 36px; font-size: 16px; border-radius: 12px; }
.btn-sm { padding: 7px 14px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ---------- 考试界面 ---------- */
.exam-meta {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; margin-bottom: 14px; flex-wrap: wrap;
}
.timer {
    display: inline-flex; align-items: center; gap: 8px;
    background: #fff; border: 1.5px solid var(--line); border-radius: 999px;
    padding: 7px 16px; font-size: 14px; font-weight: 700; color: var(--ink-2);
    box-shadow: var(--shadow);
}
.timer .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.progress-track { height: 7px; background: var(--line); border-radius: 4px; overflow: hidden; margin-bottom: 18px; }
.progress-track .bar { height: 100%; background: linear-gradient(90deg, var(--brand), #60a5fa); border-radius: 4px; transition: width .35s ease; }

/* 题号导航 */
.qnav { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.qnav button {
    width: 36px; height: 36px; border-radius: 9px;
    border: 1.5px solid var(--line); background: #fff;
    font-size: 13px; font-weight: 700; color: var(--ink-3); cursor: pointer;
    transition: all .15s;
}
.qnav button:hover { border-color: var(--brand); }
.qnav button.answered { background: var(--brand-light); border-color: var(--brand); color: var(--brand); }
.qnav button.current { background: var(--brand); border-color: var(--brand); color: #fff; transform: scale(1.08); }

.qcard { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 30px 26px; }
.qcard .qnum { font-size: 12.5px; font-weight: 700; color: var(--brand); letter-spacing: .6px; margin-bottom: 10px; }
.qcard .qtext { font-size: 17.5px; font-weight: 600; line-height: 1.75; margin-bottom: 22px; color: var(--ink); }

.opt {
    display: flex; align-items: flex-start; gap: 12px;
    border: 1.5px solid var(--line); border-radius: 11px;
    padding: 13px 15px; margin-bottom: 10px;
    cursor: pointer; transition: all .16s; font-size: 15px; line-height: 1.6;
    background: #fff;
}
.opt:hover { border-color: var(--brand); background: var(--brand-light); }
.opt .key {
    width: 27px; height: 27px; border-radius: 50%; flex-shrink: 0;
    background: var(--bg); color: var(--ink-3);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; transition: all .16s;
}
.opt.picked { border-color: var(--brand); background: var(--brand-light); }
.opt.picked .key { background: var(--brand); color: #fff; }

.exam-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 22px; gap: 10px; flex-wrap: wrap; }
.submit-zone { text-align: center; margin-top: 24px; }
.submit-zone .hint { font-size: 13px; color: var(--ink-3); margin-top: 10px; }

/* ---------- 成绩页 ---------- */
.score-hero { text-align: center; padding: 44px 26px 36px; }
.score-ring { position: relative; width: 168px; height: 168px; margin: 0 auto 22px; }
.score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-ring .num { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.score-ring .num b { font-size: 46px; font-weight: 800; line-height: 1; }
.score-ring .num i { font-style: normal; font-size: 13px; color: var(--ink-3); margin-top: 5px; }
.score-pass b { color: var(--success); }
.score-fail b { color: var(--danger); }

.summary-line { display: flex; justify-content: center; gap: 40px; margin: 6px 0 26px; flex-wrap: wrap; }
.summary-line .it { text-align: center; }
.summary-line .it b { font-size: 26px; font-weight: 800; display: block; }
.summary-line .it span { font-size: 13px; color: var(--ink-3); }
.summary-line .it.ok b { color: var(--success); }
.summary-line .it.bad b { color: var(--danger); }

/* 逐题解析 */
.review-item {
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 18px 22px; margin-bottom: 12px;
    border-left: 5px solid var(--success);
}
.review-item.wrong { border-left-color: var(--danger); }
.review-item .r-head { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 8px; }
.review-item .r-no { font-weight: 800; color: var(--ink-3); font-size: 14px; flex-shrink: 0; }
.review-item .r-title { font-size: 15px; font-weight: 600; line-height: 1.6; }
.review-item .r-tags { margin: 4px 0 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.review-item .r-exp {
    background: var(--warning-bg); border-radius: 8px; padding: 10px 14px;
    font-size: 13.5px; color: #78350f; line-height: 1.7;
}
.tag { display: inline-flex; align-items: center; padding: 3px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.tag-ok { background: var(--success-bg); color: var(--success); }
.tag-bad { background: var(--danger-bg); color: var(--danger); }
.tag-mute { background: var(--bg); color: var(--ink-3); }

/* ---------- 表格 ---------- */
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
.tbl th, .tbl td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); }
.tbl th { background: #f8fafc; color: var(--ink-3); font-weight: 700; font-size: 12.5px; white-space: nowrap; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover td { background: #f8fafc; }
.tbl .td-title { max-width: 380px; }
.tbl .td-title span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl .ops { display: flex; gap: 6px; white-space: nowrap; }

.pager { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pager button {
    min-width: 34px; height: 34px; padding: 0 9px;
    border: 1.5px solid var(--line); background: #fff; border-radius: 8px;
    font-size: 13px; cursor: pointer; transition: all .15s;
}
.pager button:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.pager button.cur { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager button:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- 后台布局 ---------- */
.admin-shell { display: flex; min-height: calc(100vh - 58px); }
.admin-side {
    width: 216px; background: #fff; border-right: 1px solid var(--line);
    padding: 18px 10px; flex-shrink: 0;
}
.admin-side button {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 12px 16px; margin-bottom: 4px;
    border: none; background: none; border-radius: 10px;
    font-size: 14.5px; font-weight: 600; color: var(--ink-2); cursor: pointer;
    transition: all .15s; text-align: left; font-family: inherit;
}
.admin-side button:hover { background: var(--bg); }
.admin-side button.cur { background: var(--brand-light); color: var(--brand); }
.admin-main { flex: 1; padding: 26px; min-width: 0; }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card {
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 20px 22px; border-top: 3px solid var(--brand);
}
.stat-card b { font-size: 30px; font-weight: 800; display: block; color: var(--ink); }
.stat-card span { font-size: 13px; color: var(--ink-3); }

/* 迷你图表 */
.mini-chart { display: flex; align-items: flex-end; gap: 10px; height: 130px; padding: 8px 4px 0; }
.mini-chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.mini-chart .col .stick { width: 70%; max-width: 42px; background: linear-gradient(180deg, #60a5fa, var(--brand)); border-radius: 6px 6px 2px 2px; min-height: 4px; transition: height .4s ease; }
.mini-chart .col .lab { font-size: 11px; color: var(--ink-3); }
.mini-chart .col .val { font-size: 11.5px; font-weight: 700; color: var(--ink-2); }

.dist-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; font-size: 13px; }
.dist-row .band { width: 74px; color: var(--ink-2); font-weight: 600; flex-shrink: 0; }
.dist-row .rail { flex: 1; height: 12px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.dist-row .fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--brand), #60a5fa); transition: width .5s ease; }
.dist-row .n { width: 54px; text-align: right; color: var(--ink-3); flex-shrink: 0; }

/* ---------- 弹窗 ---------- */
.mask {
    position: fixed; inset: 0; background: rgba(15,23,42,.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 200; padding: 18px; backdrop-filter: blur(2px);
}
.mask.hidden { display: none; }
.dialog {
    background: #fff; border-radius: 16px; width: 100%; max-width: 640px;
    max-height: 88vh; overflow-y: auto; padding: 26px;
    box-shadow: var(--shadow-lg); animation: pop .22s ease;
}
@keyframes pop { from { transform: translateY(14px); opacity: 0; } }
.dialog h3 { font-size: 17px; font-weight: 700; margin-bottom: 18px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ---------- Toast ---------- */
.toasts { position: fixed; top: 18px; right: 18px; z-index: 300; display: flex; flex-direction: column; gap: 9px; }
.toast {
    background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--brand);
    border-radius: 10px; padding: 12px 18px; font-size: 14px; min-width: 220px;
    box-shadow: var(--shadow-lg); animation: slidein .25s ease;
}
.toast.ok { border-left-color: var(--success); }
.toast.err { border-left-color: var(--danger); }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } }

/* ---------- 空状态 / 登录页 ---------- */
.empty { text-align: center; padding: 54px 18px; color: var(--ink-3); font-size: 14.5px; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
    background: linear-gradient(135deg, var(--brand-dark), var(--brand)); }
.login-card { background: #fff; border-radius: 18px; padding: 40px 34px; width: 100%; max-width: 400px; box-shadow: var(--shadow-lg); }
.login-card h1 { font-size: 21px; text-align: center; margin-bottom: 6px; }
.login-card .sub { text-align: center; color: var(--ink-3); font-size: 13.5px; margin-bottom: 26px; }

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
    .admin-shell { flex-direction: column; }
    .admin-side { width: 100%; display: flex; overflow-x: auto; padding: 8px; border-right: none; border-bottom: 1px solid var(--line); }
    .admin-side button { width: auto; white-space: nowrap; margin-bottom: 0; }
}
@media (max-width: 520px) {
    .container, .container-wide { padding: 16px 12px 40px; }
    .hero { padding: 32px 18px 28px; }
    .hero h1 { font-size: 21px; }
    .card, .qcard { padding: 18px 15px; }
    .grid-2 { grid-template-columns: 1fr; }
    .summary-line { gap: 22px; }
    .qnav button { width: 32px; height: 32px; }
}
