:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #fafbfe;
  --border: #e5e9f2;
  --border-strong: #d5dced;
  --text: #1b2436;
  --text-2: #4a5670;
  --muted: #7b879f;
  --primary: #4f46e5;
  --primary-dark: #4038c9;
  --primary-soft: #eef0ff;
  --blue: #2563eb;
  --blue-soft: #eaf1ff;
  --green: #0f9d58;
  --green-soft: #e7f6ee;
  --amber: #d97706;
  --amber-soft: #fff3e0;
  --red: #dc3545;
  --red-soft: #fdecef;
  --gray-soft: #eef1f6;
  --shadow: 0 1px 2px rgba(20, 30, 60, .04), 0 8px 24px rgba(20, 30, 60, .05);
  --radius: 14px;
  --radius-sm: 9px;
}

* { box-sizing: border-box; }

/* 作者样式里的 display:flex/grid 会盖掉 UA 对 hidden 的 display:none，必须显式兜底 */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

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

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); text-decoration: none; }

/* ---------- 通用组件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  padding: 8px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
  transition: all .15s ease; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); background: #fbfbff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-danger { color: var(--red); border-color: #f0c8ce; background: #fffafa; }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-lg { padding: 11px 20px; font-size: 14px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.card-body { padding: 22px; }

.field { margin-bottom: 16px; }
.field label, .label { display: block; font-size: 12px; font-weight: 700; color: var(--text-2); margin-bottom: 7px; letter-spacing: .2px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.input, .textarea, .select {
  width: 100%; border: 1px solid var(--border-strong); background: var(--surface);
  border-radius: var(--radius-sm); padding: 9px 12px; outline: none;
  transition: border-color .15s, box-shadow .15s; font-size: 13px;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.textarea { resize: vertical; min-height: 88px; line-height: 1.7; }
.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 d='M2 4l4 4 4-4' fill='none' stroke='%237b879f' stroke-width='1.6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-blue { background: var(--blue-soft); color: var(--blue); }
.pill-green { background: var(--green-soft); color: var(--green); }
.pill-amber { background: var(--amber-soft); color: var(--amber); }
.pill-red { background: var(--red-soft); color: var(--red); }
.pill-gray { background: var(--gray-soft); color: var(--muted); }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; padding: 11px 14px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .5px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #fbfcff; }
.cell-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .empty-icon { font-size: 30px; margin-bottom: 10px; opacity: .55; }
.empty p { margin: 0 0 4px; }

.toast-host { position: fixed; top: 18px; right: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 9999; }
.toast { min-width: 220px; max-width: 380px; padding: 11px 16px; border-radius: 10px; background: #243049; color: #fff; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.18); animation: toast-in .22s ease; }
.toast-success { background: #0f7a45; }
.toast-error { background: #c22d40; }
.toast-out { opacity: 0; transform: translateY(-8px); transition: all .25s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

.modal-mask { position: fixed; inset: 0; background: rgba(20,28,48,.42); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 500; }
.modal { background: var(--surface); border-radius: 16px; width: min(920px, 100%); max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 24px 70px rgba(15,25,50,.24); }
.modal.wide { width: min(1040px, 100%); }
.modal-head { padding: 18px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 22px 24px; overflow-y: auto; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.icon-btn { border: none; background: transparent; color: var(--muted); font-size: 20px; line-height: 1; padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { background: var(--gray-soft); color: var(--text); }

/* ---------- 首页 ---------- */
.landing { max-width: 1080px; margin: 0 auto; padding: 56px 28px 70px; }
.landing-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 52px; }
.brand { display: flex; align-items: center; gap: 11px; font-weight: 800; font-size: 16px; letter-spacing: .2px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 17px; box-shadow: 0 6px 16px rgba(79,70,229,.28); }
.hero { max-width: 760px; }
.hero .eyebrow { display: inline-block; background: var(--primary-soft); color: var(--primary); padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; margin-bottom: 20px; }
.hero h1 { font-size: 40px; line-height: 1.28; margin: 0 0 16px; letter-spacing: -.6px; }
.hero h1 em { font-style: normal; color: var(--primary); }
.hero p { font-size: 16px; color: var(--text-2); margin: 0 0 28px; line-height: 1.85; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.rule-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 56px; }
.rule-card { padding: 22px; }
.rule-num { font-size: 12px; font-weight: 800; color: var(--primary); background: var(--primary-soft); display: inline-block; padding: 3px 9px; border-radius: 6px; margin-bottom: 14px; }
.rule-card h4 { margin: 0 0 8px; font-size: 15px; }
.rule-card p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.75; }
.landing-foot { margin-top: 44px; padding-top: 22px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; line-height: 1.9; }

/* ---------- 管理后台 ---------- */
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1000px 500px at 50% -10%, #e9ebff 0%, var(--bg) 65%); }
.auth-card { width: min(420px, 100%); padding: 32px; }
.auth-card .brand { margin-bottom: 26px; }
.auth-card h2 { margin: 0 0 6px; font-size: 21px; }
.auth-card .sub { color: var(--muted); font-size: 13px; margin: 0 0 24px; }
.auth-note { margin-top: 18px; padding: 12px 14px; background: var(--primary-soft); color: var(--primary-dark); border-radius: 9px; font-size: 12px; line-height: 1.7; }
.auth-error { color: var(--red); font-size: 12px; min-height: 18px; margin-top: 8px; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 232px; flex: none; background: #fff; border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { padding: 22px 20px; border-bottom: 1px solid var(--border); }
.side-nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px; color: var(--text-2); font-size: 13px; font-weight: 600; border: none; background: transparent; width: 100%; text-align: left; }
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.nav-item .ic { width: 18px; text-align: center; font-size: 15px; }
.side-foot { padding: 14px 18px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); }
.side-foot .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-right: 6px; }

.main { flex: 1; min-width: 0; }
.topbar { height: 62px; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 28px; position: sticky; top: 0; z-index: 20; }
.topbar h2 { margin: 0; font-size: 16px; }
.topbar .right { display: flex; align-items: center; gap: 12px; }
.topbar .who { font-size: 12px; color: var(--muted); }
.page { padding: 26px 28px 60px; max-width: 1400px; }

.kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 22px; }
.kpi { padding: 18px 20px; }
.kpi .k-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .k-value { font-size: 28px; font-weight: 800; letter-spacing: -.5px; margin-top: 6px; }
.kpi .k-foot { font-size: 11px; color: var(--muted); margin-top: 2px; }
.kpi.accent .k-value { color: var(--primary); }

.two-col { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; align-items: start; }
.section-title { font-size: 14px; font-weight: 700; margin: 0 0 14px; }

.event-item { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px dashed var(--border); font-size: 12px; }
.event-item:last-child { border-bottom: none; }
.event-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: 6px; flex: none; opacity: .65; }
.event-time { color: var(--muted); white-space: nowrap; }
.event-text { color: var(--text-2); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .input, .toolbar .select { width: auto; min-width: 160px; }
.toolbar .spacer { flex: 1; }

.issue-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 20px; align-items: start; }
.issued-list { max-height: 330px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.issued-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.issued-row:last-child { border-bottom: none; }
.issued-row .name { font-weight: 600; min-width: 84px; }
.issued-row .url { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; font-family: ui-monospace, Consolas, monospace; }

.q-row { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 10px; background: var(--surface-2); }
.q-row-head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.q-row-head .idx { font-size: 11px; font-weight: 800; color: var(--primary); background: var(--primary-soft); padding: 2px 8px; border-radius: 6px; }
.q-row-head .spacer { flex: 1; }
.q-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 10px; }
.opt-row { display: flex; gap: 8px; align-items: center; margin-bottom: 7px; }
.opt-row .input { flex: 1; }
.opt-row .input.score { width: 92px; flex: none; }
.mini-label { font-size: 11px; color: var(--muted); font-weight: 700; margin: 10px 0 6px; }
.dim-row, .range-row { display: grid; grid-template-columns: 1fr 1.4fr 1fr 32px; gap: 8px; margin-bottom: 8px; align-items: center; }
.range-row { grid-template-columns: 74px 74px 1fr 1.6fr 32px; }

.detail-grid { display: grid; grid-template-columns: 150px 1fr; gap: 10px 16px; font-size: 13px; }
.detail-grid dt { color: var(--muted); }
.detail-grid dd { margin: 0; }
.bar-track { height: 8px; border-radius: 99px; background: var(--gray-soft); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; background: var(--primary); }

/* ---------- 答题端 ---------- */
.take-shell { min-height: 100vh; background: linear-gradient(180deg, #f0f2ff 0%, var(--bg) 260px); padding: 30px 18px 60px; }
.take-container { max-width: 720px; margin: 0 auto; }
.take-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.take-head .brand { font-size: 14px; }
.countdown { background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; font-size: 12px; font-weight: 700; color: var(--text-2); box-shadow: var(--shadow); }
.countdown strong { font-family: ui-monospace, Consolas, monospace; color: var(--primary); font-size: 13px; }
.countdown.urgent { color: var(--red); border-color: #f0c8ce; }
.countdown.urgent strong { color: var(--red); }

.take-card { padding: 30px 32px; }
.take-intro h1 { font-size: 24px; margin: 0 0 10px; }
.take-intro .meta { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.notice { background: var(--primary-soft); border: 1px solid #dfe1ff; border-radius: 10px; padding: 14px 16px; font-size: 12px; color: var(--primary-dark); line-height: 1.8; margin: 18px 0 24px; }
.notice b { color: var(--primary); }

.progress-line { height: 6px; background: var(--gray-soft); border-radius: 99px; overflow: hidden; margin-bottom: 8px; }
.progress-line > div { height: 100%; background: var(--primary); border-radius: 99px; transition: width .25s ease; }
.progress-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 26px; }
.q-title { font-size: 18px; font-weight: 700; line-height: 1.6; margin: 0 0 20px; }
.q-title .q-num { color: var(--primary); margin-right: 8px; }
.options { display: flex; flex-direction: column; gap: 10px; }
.option { display: flex; align-items: center; gap: 12px; border: 1px solid var(--border-strong); border-radius: 10px; padding: 12px 15px; cursor: pointer; background: #fff; transition: all .15s; font-size: 14px; }
.option:hover { border-color: var(--primary); background: #fbfbff; }
.option.selected { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
.option input { accent-color: var(--primary); width: 16px; height: 16px; }
.scale-options { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.scale-options .option { flex-direction: column; gap: 6px; padding: 14px 6px; text-align: center; font-size: 12px; }
.scale-options .option .big { font-size: 18px; font-weight: 800; }
.scale-ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 8px; }
.text-answer { min-height: 110px; }
.quiz-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); }
.save-hint { font-size: 12px; color: var(--muted); }

.state-card { text-align: center; padding: 48px 32px; }
.state-icon { width: 62px; height: 62px; border-radius: 18px; display: grid; place-items: center; margin: 0 auto 20px; font-size: 28px; }
.state-icon.bad { background: var(--red-soft); color: var(--red); }
.state-icon.warn { background: var(--amber-soft); color: var(--amber); }
.state-icon.good { background: var(--green-soft); color: var(--green); }
.state-card h1 { font-size: 21px; margin: 0 0 10px; }
.state-card p { color: var(--text-2); margin: 0 auto 8px; max-width: 460px; line-height: 1.85; font-size: 13px; }
.state-card .reason { background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 10px 14px; font-size: 12px; color: var(--muted); margin: 18px auto 0; max-width: 460px; }

.result-head { text-align: center; padding-bottom: 22px; border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.result-head .score { font-size: 46px; font-weight: 800; color: var(--primary); letter-spacing: -1px; line-height: 1.2; }
.result-head .score small { font-size: 15px; color: var(--muted); font-weight: 600; }
.result-head .level { display: inline-block; margin-top: 8px; }
.result-text { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; font-size: 13px; line-height: 1.9; color: var(--text-2); margin-bottom: 22px; }
.dim-item { margin-bottom: 16px; }
.dim-item .dim-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.dim-item .dim-name { font-weight: 700; }
.dim-item .dim-desc { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .two-col, .issue-grid { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
  .sidebar { width: 64px; }
  .sidebar .brand span, .nav-item span:not(.ic), .side-foot { display: none; }
  .sidebar .brand { justify-content: center; padding: 18px 0; }
  .nav-item { justify-content: center; }
  .page { padding: 20px 16px 50px; }
  .topbar { padding: 0 16px; }
  .kpi-grid, .rule-grid { grid-template-columns: repeat(2, 1fr); }
  .take-card { padding: 24px 20px; }
  .scale-options { grid-template-columns: repeat(5, 1fr); }
  .hero h1 { font-size: 30px; }
}
