/* ============================================
 * style.css — 问卷研究工作室 · 多期追踪问卷工具
 * 视觉风格与原站「沐森心理研究工作室」一致：
 * 柔和蓝 (#2c3e7a) / 灰白 (#f5f7fa) / 紫色点缀 (#6c2d82)
 * ============================================ */

/* ---- CSS 变量（复用原站 :root） ---- */
:root {
    --primary: #2c3e7a;
    --primary-light: #3a5aad;
    --primary-dark: #1a264f;
    --accent: #e67e22;
    --accent-light: #f39c12;
    --bg: #f5f7fa;
    --bg-card: #ffffff;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --text-white: #ffffff;
    --border: #e8ecf1;
    --purple: #6c2d82;
    --purple-bg: #e8d5f5;
    --green: #155724;
    --green-bg: #d4edda;
    --red: #a02c2c;
    --red-bg: #f8d7da;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.15);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s ease;
    --max-width: 1200px;
    --header-height: 64px;

    /* ---- 科技感令牌（与主站 style.css 同名同色，保证全站一致）---- */
    --tech-cyan: #22d3ee;
    --tech-cyan-soft: #7dd3fc;
    --tech-blue: #2563eb;
    --tech-violet: #8b5cf6;
    --tech-ink: #0a1124;
    --tech-panel: rgba(255, 255, 255, 0.82);
    --tech-panel-strong: rgba(255, 255, 255, 0.94);
    --tech-line: rgba(34, 211, 238, 0.28);
    --tech-grid: rgba(125, 211, 252, 0.10);
    --tech-glow: 0 0 0 1px rgba(34, 211, 238, 0.18), 0 10px 30px rgba(10, 17, 36, 0.10);
    --tech-glow-hover: 0 0 0 1px rgba(34, 211, 238, 0.40), 0 18px 44px rgba(10, 17, 36, 0.16),
                       0 0 26px rgba(34, 211, 238, 0.18);
    --tech-gradient: linear-gradient(135deg, #0f1a3d 0%, #1b2a63 34%, #2c3e7a 62%, #1d4ed8 100%);
    --tech-gradient-bar: linear-gradient(90deg, transparent, var(--tech-cyan), var(--tech-violet), transparent);
}

/* ---- 基础重置 ---- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Microsoft YaHei", "Helvetica Neue", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary-light); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--accent); }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--text); }

/* ---- 顶部导航 ---- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .topbar { -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
}
.topbar-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}
.topbar-brand .logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--primary);
    color: #fff;
    border-radius: 8px;
    font-size: 17px;
}
.topbar-brand small { font-weight: 400; color: var(--text-light); font-size: 12px; }

.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* 顶栏右侧操作区：返回主页入口 + 登录态 */
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-left: auto;
}
/* 「返回主页」入口（回到主站首页，非本工具内部路由） */
.topbar-home {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-card);
    color: var(--primary);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1.2;
    flex: 0 0 auto;
    -webkit-transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
    transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}
.topbar-home:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--text-white);
}
.topbar-home .home-icon { font-size: 14px; line-height: 1; }
.nav-user { display: flex; align-items: center; gap: 8px; }
.nav-nick { font-weight: 600; color: var(--text); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 角色徽章 */
.role-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.role-admin { background: var(--purple-bg); color: var(--purple); }
.role-user  { background: #d1ecf1; color: #0c5460; }

/* ---- 主容器 ---- */
.app-wrap { max-width: var(--max-width); margin: 0 auto; padding: 28px 24px 60px; min-height: calc(100vh - var(--header-height)); }

/* ---- 页面加载遮罩 ---- */
#page-loading {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(245, 247, 250, 0.85);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    font-size: 15px;
    color: var(--text-light);
}
.spinner {
    width: 34px; height: 34px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- 页面标题区 ---- */
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.page-head h1 { font-size: 24px; color: var(--primary-dark); font-weight: 700; }
.page-head p { color: var(--text-light); font-size: 14px; margin-top: 4px; }
.page-head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.breadcrumb {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 16px;
}
.breadcrumb a { color: var(--primary-light); }

/* ---- 卡片 ---- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 22px;
    margin-bottom: 20px;
    transition: var(--transition);
    border: 1px solid transparent;
}
.card:hover { box-shadow: var(--shadow-hover); }
.card-title { font-size: 16px; font-weight: 700; color: var(--primary-dark); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }

/* ---- 按钮 ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    line-height: 1.4;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-accent  { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-light); }
.btn-ghost   { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-ghost:hover { background: rgba(44, 62, 122, 0.06); }
.btn-danger  { background: transparent; color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red-bg); }
.btn-success { background: var(--green); color: #fff; }
.btn-soft    { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-soft:hover { border-color: var(--primary-light); color: var(--primary); }
.btn-xs { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ---- 表格 ---- */
.table-wrap { overflow-x: auto; }
table.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.table th {
    text-align: left;
    padding: 12px 14px;
    background: var(--bg);
    color: var(--text-light);
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tbody tr { transition: background 0.2s; }
.table tbody tr:hover { background: rgba(58, 90, 173, 0.04); }
.table .row-title { font-weight: 600; color: var(--primary-dark); }

/* ---- 问卷模板管理（超管中心） ---- */
.tpl-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

/* ---- 可排序表格：工具条 + 排序表头 + 分页器 ---- */
.table-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}
.table-toolbar .sc-search { width: 260px; max-width: 100%; margin: 0; }
.table-toolbar-info { font-size: 13px; color: var(--text-light); }
.table-toolbar-info b { color: var(--primary-dark); }
.table-toolbar-spacer { flex: 1 1 auto; }
.table-size { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-light); }
.table-size .input { width: auto; margin: 0; padding: 4px 8px; }

.table-sortable .th-sort {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.table-sortable .th-sort:hover { color: var(--primary); background: rgba(58, 90, 173, 0.06); }
.table-sortable .th-sort.active { color: var(--primary-dark); }
.table-sortable .th-sort .sort-ind {
    display: inline-block;
    margin-left: 4px;
    font-style: normal;
    font-size: 11px;
    opacity: .45;
}
.table-sortable .th-sort.active .sort-ind { opacity: 1; }

.table-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
}
.table-pager-info { font-size: 13px; color: var(--text-light); margin: 0 6px; }
.table-pager-info b { color: var(--primary-dark); }
.table-pager .btn[disabled] { opacity: .45; cursor: not-allowed; }

@media (max-width: 640px) {
    .table-toolbar .sc-search { width: 100%; }
    .table-toolbar-spacer { display: none; }
}

/* 状态徽章 */
.st-draft, .st-published, .st-closed, .badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.st-draft    { background: var(--bg); color: var(--text-light); border: 1px solid var(--border); }
.st-published{ background: var(--green-bg); color: var(--green); }
.st-closed   { background: var(--red-bg); color: var(--red); }
.badge-blue   { background: #d1ecf1; color: #0c5460; }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-orange { background: #fff3cd; color: #856404; }
.badge-green  { background: var(--green-bg); color: var(--green); }

/* 表格操作按钮组 */
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions .btn-xs { font-weight: 500; }

/* ---- 表单 ---- */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; color: var(--text); }
.form-group label .req { color: var(--red); margin-left: 2px; }
.form-hint { font-size: 12px; color: var(--text-light); margin-top: 4px; }
.input, textarea.input, select.input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: var(--transition);
    background: #fff;
}
.input:focus { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(58, 90, 173, 0.12); }
textarea.input { resize: vertical; min-height: 80px; line-height: 1.6; }
.input-sm { padding: 6px 10px; font-size: 13px; }

.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 200px; }

/* 开关 */
.switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; gap: 10px; }
.switch input { display: none; }
.switch .track {
    width: 46px; height: 26px;
    background: #d3d9e0;
    border-radius: 999px;
    position: relative;
    transition: background 0.25s;
    flex-shrink: 0;
}
.switch .track::after {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 20px; height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.25s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch .switch-label { font-weight: 600; font-size: 14px; }

/* ---- Toast ---- */
#toast-container {
    position: fixed;
    top: 74px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 340px;
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: #fff;
    color: var(--text);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-hover);
    font-size: 14px;
    border-left: 4px solid var(--primary-light);
    animation: toastIn 0.3s ease;
    word-break: break-all;
}
.toast-success { border-left-color: #28a745; }
.toast-error   { border-left-color: var(--red); }
.toast-loading { border-left-color: var(--accent); }
.toast-icon { font-weight: 700; }
.toast-out { opacity: 0; transform: translateX(20px); transition: all 0.3s; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ---- 弹层 ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26, 38, 79, 0.5);
    z-index: 2500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s;
}
.modal {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-hover);
    width: 100%;
    max-width: 480px;
    padding: 24px;
    animation: popIn 0.25s ease;
}
.modal-lg { max-width: 720px; }
.modal-sm { max-width: 400px; }
.modal-title { font-size: 17px; color: var(--primary-dark); margin-bottom: 12px; }
.modal-msg { color: var(--text); font-size: 14px; line-height: 1.7; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal-out { opacity: 0; transition: opacity 0.2s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { transform: scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- 空状态 ---- */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-light); }
.empty-icon { font-size: 42px; margin-bottom: 10px; }

/* ---- 认证页（登录/注册） ---- */
.auth-wrap { max-width: 460px; margin: 30px auto; }
.auth-card { padding: 32px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 24px; }
.auth-tab {
    flex: 1;
    text-align: center;
    padding: 10px;
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text-light);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}
.auth-tab.active { background: var(--primary); color: #fff; }
.auth-submit { width: 100%; margin-top: 6px; }
.auth-mode-note {
    font-size: 12px;
    color: var(--text-light);
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    margin-bottom: 16px;
    text-align: center;
}

/* ---- 后台布局 ---- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 14px;
}
.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    background: rgba(44, 62, 122, 0.08);
}
.stat-info .stat-num { font-size: 24px; font-weight: 800; color: var(--primary-dark); }
.stat-info .stat-label { font-size: 13px; color: var(--text-light); }

/* ---- 编辑器 ---- */
.editor-toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.editor-section { border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; background: #fff; }
.editor-section-title { font-size: 15px; font-weight: 700; color: var(--primary-dark); margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }

/* 题目卡片 */
.question-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 14px;
    background: var(--bg-card);
    transition: var(--transition);
    position: relative;
}
.question-card:hover { border-color: var(--primary-light); box-shadow: var(--shadow); }
.question-card .q-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.q-index {
    flex-shrink: 0;
    width: 28px; height: 28px;
    background: var(--primary);
    color: #fff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
}
.q-title-input { flex: 1; min-width: 240px; }
.q-meta { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.q-meta label { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text-light); cursor: pointer; }
.q-options-list { margin-top: 6px; }
.q-option-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.q-option-row .input { flex: 1; }
.q-option-row .btn-xs { flex-shrink: 0; }
.q-card-actions { display: flex; gap: 6px; margin-top: 8px; border-top: 1px dashed var(--border); padding-top: 10px; }

/* 跳转规则 */
.jump-rule-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; background: var(--bg); border-radius: var(--radius-sm); padding: 10px 12px; }
.jump-rule-row select { min-width: 150px; }

/* ---- 作答页 ---- */
.answer-wrap { max-width: 820px; margin: 0 auto; }
.answer-title { text-align: center; margin-bottom: 6px; }
.answer-desc { text-align: center; color: var(--text-light); margin-bottom: 24px; }
.answer-progress { display: flex; justify-content: center; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }
.answer-progress .dot { width: 26px; height: 6px; border-radius: 3px; background: var(--border); }
.answer-progress .dot.done { background: var(--primary-light); }
.answer-progress .dot.current { background: var(--accent); }

.answer-question {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 24px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}
.answer-question.current-q { border-color: var(--primary-light); }
.q-title { font-size: 16px; font-weight: 700; color: var(--primary-dark); margin-bottom: 4px; }
.q-title .qno { color: var(--accent); margin-right: 6px; }
.q-required-mark { color: var(--red); margin-left: 4px; }
.q-desc { color: var(--text-light); font-size: 13px; margin-bottom: 12px; }
.q-options { margin-top: 8px; }

/* 单/多选题选项 */
.opt-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition);
    background: #fff;
    user-select: none;
}
.opt-item:hover { border-color: var(--primary-light); background: rgba(58, 90, 173, 0.04); }
.opt-item.selected { border-color: var(--primary); background: rgba(44, 62, 122, 0.07); box-shadow: 0 0 0 2px rgba(44, 62, 122, 0.15); }
.opt-item input { accent-color: var(--primary); width: 16px; height: 16px; flex-shrink: 0; }

/* 量表题按钮 */
.scale-group { display: flex; gap: 10px; flex-wrap: wrap; }
.scale-btn {
    flex: 1;
    min-width: 52px;
    max-width: 80px;
    text-align: center;
    padding: 14px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 600;
    color: var(--text-light);
    position: relative;
}
.scale-btn:hover { border-color: var(--primary-light); color: var(--primary); }
.scale-btn.selected {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(44, 62, 122, 0.18);
}
.scale-btn .scale-label { display: block; font-size: 11px; font-weight: 400; opacity: 0.75; margin-top: 2px; }

/* 必答校验错误 */
.q-error { border-color: var(--red) !important; box-shadow: 0 0 0 2px rgba(160, 44, 44, 0.15); }
.error-msg { color: var(--red); font-size: 13px; margin-top: 6px; display: none; }
.error-msg.show { display: block; }

.answer-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 20px; flex-wrap: wrap; }

/* ---- 纵向追踪 ---- */
.track-summary {
    background: linear-gradient(135deg, #1a264f 0%, #2c3e7a 60%, #3a5aad 100%);
    color: #fff;
    border-radius: var(--radius);
    padding: 22px 26px;
    margin-bottom: 20px;
}
.track-summary h2 { font-size: 20px; margin-bottom: 6px; }
.track-summary .track-meta { display: flex; gap: 24px; flex-wrap: wrap; font-size: 14px; opacity: 0.9; }
.track-summary .track-meta b { font-size: 22px; margin-right: 4px; }

.track-chart-card { background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.chart-box { position: relative; height: 320px; }

.record-card { background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 22px; margin-bottom: 14px; border-left: 4px solid var(--primary-light); }
.record-card .record-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.record-batch { font-weight: 800; color: var(--primary); font-size: 15px; }
.record-time { color: var(--text-light); font-size: 13px; }
.record-answers { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px 18px; }
.record-ans { font-size: 13px; display: flex; gap: 8px; }
.record-ans .ans-q { color: var(--text-light); flex-shrink: 0; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-ans .ans-v { font-weight: 600; color: var(--text); }
.record-ans .ans-v.changed { color: var(--accent); background: rgba(230, 126, 34, 0.12); padding: 1px 6px; border-radius: 4px; }
.record-ans .ans-v.new { color: var(--purple); background: rgba(108, 45, 130, 0.12); padding: 1px 6px; border-radius: 4px; }

/* ---- 个人中心 ---- */
.panel-tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.panel-tab { padding: 8px 18px; border-radius: 999px; background: var(--bg); color: var(--text-light); font-weight: 600; cursor: pointer; transition: var(--transition); font-size: 14px; border: 1px solid transparent; }
.panel-tab.active { background: var(--primary); color: #fff; }
.panel-tab .count { background: rgba(255,255,255,0.2); border-radius: 999px; padding: 0 8px; margin-left: 6px; font-size: 12px; }
.panel-tab:not(.active) .count { background: rgba(44,62,122,0.1); }

.survey-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.survey-item .si-info { flex: 1; min-width: 220px; }
.survey-item .si-title { font-weight: 700; color: var(--primary-dark); font-size: 15px; }
.survey-item .si-meta { font-size: 12px; color: var(--text-light); margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; }
.survey-item .si-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* 第 N 次作答标签 */
.batch-tag { background: var(--purple-bg); color: var(--purple); font-weight: 700; font-size: 12px; padding: 1px 8px; border-radius: 999px; }

/* ---- 统计视图 ---- */
.stat-question { background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.stat-question h3 { font-size: 15px; color: var(--primary-dark); margin-bottom: 4px; }
.stat-question .sq-meta { font-size: 13px; color: var(--text-light); margin-bottom: 14px; }
.stat-question canvas { max-height: 260px; }
.stat-avg { color: var(--accent); font-weight: 700; }

/* 变化高亮（追踪对比表） */
.diff-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.diff-table th, .diff-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: center; }
.diff-table th { background: var(--bg); font-weight: 600; color: var(--text-light); }
.diff-cell.up { color: var(--red); font-weight: 700; }
.diff-cell.down { color: var(--green); font-weight: 700; }
.diff-cell.same { color: var(--text-light); }
.diff-cell.changed { color: var(--accent); font-weight: 700; background: rgba(230,126,34,0.1); }

/* ---- 响应式 ---- */
@media (max-width: 768px) {
    .topbar-inner { padding: 0 14px; gap: 10px; }
    .topbar-actions { gap: 8px; }
    .topbar-home { padding: 6px 11px; font-size: 12px; }
    .app-wrap { padding: 20px 14px 50px; }
    .page-head h1 { font-size: 20px; }
    .topbar-brand small { display: none; }
    .answer-question { padding: 18px 16px; }
    .scale-btn { max-width: none; min-width: 44px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .record-answers { grid-template-columns: 1fr; }
    .track-summary .track-meta { gap: 12px; }
    .card { padding: 16px; }
}
@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
    .row-actions .btn-xs { padding: 4px 8px; font-size: 11px; }
    /* 顶栏允许纵向增长：万一换行也是撑高而不是溢出压住页面内容 */
    .topbar { height: auto; min-height: var(--header-height); padding: 6px 0; }
    .topbar-inner { gap: 8px; }
    .topbar-actions { gap: 6px; }
    /* 极窄屏下「返回主页」只留图标，避免顶栏换行溢出 */
    .topbar-home .home-text { display: none; }
    .topbar-home { padding: 7px 10px; }
    .topbar-brand { font-size: 16px; }
}
/* 超窄屏（≤380px）：品牌名与图标再缩一档，保证与右侧操作同排一行 */
@media (max-width: 380px) {
    .topbar-brand { font-size: 15px; gap: 8px; }
    .topbar-brand .logo-icon { width: 30px; height: 30px; font-size: 14px; border-radius: 6px; }
    .topbar-home { padding: 6px 9px; }
}

/* ============================================================
 * 科技感主题层（Tech / Sci-fi layer）
 * ------------------------------------------------------------
 * 与主站 /assets/css/style.css 同一套令牌与手法：
 *   网格底纹 / 环境光晕 / 玻璃拟态 / 渐变描边 / 发光交互。
 *
 * 自我约束（与本工具的后台数据可读性直接相关）：
 *   1. 只覆盖配色、背景、边框、阴影、伪元素与 transform；
 *      不碰 display / 尺寸 / padding 等布局属性，避免打乱各断点，
 *      也避免覆盖 ≤480px 顶栏可增长等响应式规则。
 *   2. 表格与表单保持浅底深字（≥7:1），科技感只体现在表头、
 *      描边与交互高光上，不影响长时间读数据的舒适度。
 *   3. backdrop-filter 放在 @supports 内，旧内核/极速模式退化为纯色。
 * ============================================================ */

/* ---- 1. 页面氛围 ---- */
body {
    background-color: var(--bg);
    background-image:
        radial-gradient(760px 420px at 8% -8%, rgba(34, 211, 238, 0.10), transparent 72%),
        radial-gradient(680px 380px at 96% 4%, rgba(139, 92, 246, 0.09), transparent 74%),
        linear-gradient(var(--tech-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--tech-grid) 1px, transparent 1px);
    background-size: auto, auto, 52px 52px, 52px 52px;
    background-repeat: no-repeat, no-repeat, repeat, repeat;
    background-attachment: fixed, fixed, fixed, fixed;
}

#page-loading {
    background: rgba(245, 247, 250, 0.86);
}

.spinner {
    border-color: rgba(34, 211, 238, 0.25);
    border-top-color: var(--tech-cyan);
    box-shadow: 0 0 18px rgba(34, 211, 238, 0.35);
}

/* ---- 2. 顶栏：玻璃拟态 + 底部光带 ---- */
.topbar {
    background: rgba(255, 255, 255, 0.90);
    border-bottom: 1px solid rgba(34, 211, 238, 0.30);
}

.topbar::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 1px;
    background: var(--tech-gradient-bar);
    opacity: 0.75;
    pointer-events: none;
}

@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .topbar {
        background: rgba(255, 255, 255, 0.74);
        -webkit-backdrop-filter: blur(16px) saturate(1.5);
        backdrop-filter: blur(16px) saturate(1.5);
    }
}

.topbar-brand .logo-icon {
    background: linear-gradient(135deg, var(--primary-light), var(--primary) 52%, var(--tech-blue));
    box-shadow: 0 6px 18px rgba(29, 78, 216, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.topbar-home {
    border-color: rgba(34, 211, 238, 0.40);
    box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.10), 0 6px 18px rgba(10, 17, 36, 0.06);
}

.topbar-home:hover {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-color: var(--primary-light);
    box-shadow: 0 8px 22px rgba(44, 62, 122, 0.28), 0 0 20px rgba(34, 211, 238, 0.28);
}

/* ---- 3. 页面标题 / 面包屑 ---- */
.page-head h1 {
    position: relative;
    padding-bottom: 8px;
}

.page-head h1::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 56px;
    height: 3px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--tech-cyan), var(--tech-violet), transparent);
    box-shadow: 0 0 12px rgba(34, 211, 238, 0.45);
}

.breadcrumb a {
    color: var(--primary-light);
}

.breadcrumb a:hover {
    color: var(--tech-blue);
}

/* ---- 4. 面板族：玻璃拟态 + 渐变描边 + 悬停发光 ---- */
.card,
.stat-card,
.stat-question,
.answer-question,
.track-chart-card {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.84)) padding-box,
        linear-gradient(140deg, rgba(34, 211, 238, 0.45), rgba(139, 92, 246, 0.26) 50%, rgba(34, 211, 238, 0.14)) border-box;
    border: 1px solid transparent;
    box-shadow: var(--tech-glow);
}

.card:hover,
.stat-card:hover,
.answer-question.current-q {
    box-shadow: var(--tech-glow-hover);
}

.answer-question.current-q {
    border-color: transparent;
}

.stat-icon {
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.18), rgba(37, 99, 235, 0.12));
    box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.30), 0 0 16px rgba(34, 211, 238, 0.18);
}

.stat-info .stat-num {
    text-shadow: 0 0 18px rgba(34, 211, 238, 0.28);
}

/* 面板切换标签 */
.panel-tab {
    border: 1px solid transparent;
}

.panel-tab.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-light) 65%, var(--tech-blue));
    color: #fff;
    box-shadow: 0 8px 20px rgba(44, 62, 122, 0.24),
                0 0 0 1px rgba(34, 211, 238, 0.35),
                0 0 16px rgba(34, 211, 238, 0.20);
}

/* ---- 5. 按钮：渐变 + 发光 + 掠过高光 ---- */
.btn {
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background-image: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 62%, var(--tech-blue) 100%);
    box-shadow: 0 6px 18px rgba(44, 62, 122, 0.24), 0 0 0 1px rgba(34, 211, 238, 0.20);
}

.btn-accent {
    background-image: linear-gradient(135deg, #c2410c 0%, var(--accent) 55%, #fbbf24 100%);
    box-shadow: 0 6px 18px rgba(194, 65, 12, 0.22), 0 0 0 1px rgba(251, 191, 36, 0.26);
}

.btn-primary:hover,
.btn-accent:hover {
    box-shadow: 0 10px 26px rgba(44, 62, 122, 0.28),
                0 0 22px rgba(34, 211, 238, 0.30),
                0 0 0 1px rgba(34, 211, 238, 0.42);
}

.btn::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -65%;
    width: 45%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.40), transparent);
    transform: skewX(-18deg);
    transition: left 0.6s ease;
    pointer-events: none;
}

.btn:hover::after {
    left: 125%;
}

.btn-ghost {
    border-color: rgba(44, 62, 122, 0.45);
}

.btn-ghost:hover {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    box-shadow: 0 8px 22px rgba(44, 62, 122, 0.24), 0 0 18px rgba(34, 211, 238, 0.22);
}

.btn-soft:hover {
    border-color: rgba(34, 211, 238, 0.55);
    box-shadow: 0 0 14px rgba(34, 211, 238, 0.18);
}

/* ---- 6. 徽章 / 表单 / 开关 ---- */
.role-badge,
.st-draft,
.st-published,
.st-closed,
.badge {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45), 0 0 12px rgba(34, 211, 238, 0.14);
}

.input:focus {
    border-color: var(--tech-cyan);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.16);
}

.switch input:checked + .track {
    background: linear-gradient(135deg, var(--primary), var(--tech-blue));
    box-shadow: 0 0 16px rgba(34, 211, 238, 0.35);
}

/* 量表题按钮：选中态给出明确的科技感高光 */
.scale-btn.active,
.scale-btn.selected {
    border-color: var(--tech-cyan);
    box-shadow: 0 0 16px rgba(34, 211, 238, 0.28);
}

/* ---- 7. 表格：只给表头与交互上科技感，正文保持高对比 ---- */
.table th {
    background: linear-gradient(180deg, rgba(240, 249, 255, 1), rgba(235, 245, 255, 1));
    color: var(--primary);
    border-bottom: 2px solid rgba(34, 211, 238, 0.45);
}

.table tbody tr:hover {
    background: rgba(34, 211, 238, 0.06);
}

/* ---- 8. 弹层 / Toast / 空状态 ---- */
.modal {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.94)) padding-box,
        linear-gradient(140deg, rgba(34, 211, 238, 0.55), rgba(139, 92, 246, 0.30)) border-box;
    border: 1px solid transparent;
    box-shadow: 0 24px 60px rgba(10, 17, 36, 0.28), 0 0 30px rgba(34, 211, 238, 0.16);
}

.toast {
    box-shadow: 0 14px 34px rgba(10, 17, 36, 0.18), 0 0 20px rgba(34, 211, 238, 0.14);
}

.empty-state .empty-icon {
    filter: drop-shadow(0 0 16px rgba(34, 211, 238, 0.35));
}

/* ---- 9. 动效偏好 ---- */
@media (prefers-reduced-motion: reduce) {
    .btn::after {
        display: none;
    }
}

/* ============================================================
 * 10. 角色工作台（三档角色卡片 / 角色徽章 / 团队与分发控件）
 * ============================================================ */

/* 角色徽章配色 */
.role-free  { background: #e2e8f0; color: #334155; }
.role-vip   { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e; }
.role-admin { background: linear-gradient(135deg, #ede9fe, #ddd6fe); color: #5b21b6; }

/* 首页入口卡片（工作台） */
.entry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 250px));
    justify-content: start;
    gap: 20px;
}
.entry-card {
    aspect-ratio: 1 / 1;
    flex-direction: column;
    align-items: flex-start;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 22px 20px;
    border-radius: var(--radius);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.86)) padding-box,
        linear-gradient(140deg, rgba(34, 211, 238, 0.45), rgba(139, 92, 246, 0.26) 50%, rgba(34, 211, 238, 0.14)) border-box;
    border: 1px solid transparent;
    box-shadow: var(--tech-glow);
    color: var(--text);
    text-decoration: none;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.entry-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--tech-glow-hover);
    color: var(--text);
}
.entry-card .entry-icon {
    flex: 0 0 auto;
    width: 58px;
    height: 58px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.18), rgba(37, 99, 235, 0.12));
    box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.28);
}
.entry-card .entry-body { flex: 1 1 auto; min-width: 0; margin-top: 14px; }
.entry-card .entry-body strong { display: block; font-size: 16px; color: var(--primary-dark); }
.entry-card .entry-body em {
    display: block;
    font-style: normal;
    font-size: 12.5px;
    color: var(--text-light);
    margin-top: 4px;
    line-height: 1.6;
}
.entry-card .entry-arrow {
    flex: 0 0 auto;
    align-self: flex-end;
    margin-top: auto;
    color: var(--primary-light);
    font-size: 20px;
    font-weight: 700;
}
.entry-card.accent-vip {
    background:
        linear-gradient(180deg, rgba(255, 251, 235, 0.96), rgba(255, 251, 235, 0.86)) padding-box,
        linear-gradient(140deg, rgba(251, 191, 36, 0.6), rgba(245, 158, 11, 0.3)) border-box;
}
.entry-card.accent-admin {
    background:
        linear-gradient(180deg, rgba(245, 243, 255, 0.96), rgba(245, 243, 255, 0.86)) padding-box,
        linear-gradient(140deg, rgba(139, 92, 246, 0.6), rgba(99, 102, 241, 0.3)) border-box;
}

/* 角色说明列表 */
.ws-legend { display: grid; gap: 8px; font-size: 13.5px; color: var(--text); }
.ws-legend > div { display: flex; align-items: flex-start; gap: 8px; line-height: 1.7; }

/* 轻量加载提示 */
.loading-inline { color: var(--text-light); font-size: 13.5px; padding: 6px 0; }

/* 分发勾选列表 */
.as-list { display: grid; gap: 6px; max-height: 300px; overflow-y: auto; margin-top: 6px; }
.as-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    cursor: pointer;
}
.as-row:hover { border-color: var(--tech-cyan); background: rgba(34, 211, 238, 0.05); }
.as-row input { flex: 0 0 auto; }
.as-row span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.as-row em { font-style: normal; }

/* 弹层内容区（workspace.js 的 modal） */
.modal-body { max-height: 60vh; overflow-y: auto; }
.modal-title { word-break: break-all; }

/* ---- 11. 问卷二维码弹层 ---- */
.qr-modal { max-width: 420px; text-align: center; }
.qr-box {
    margin: 16px auto 10px;
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.qr-box canvas,
.qr-box img {
    border-radius: 10px;
    box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.35), 0 10px 26px rgba(10, 17, 36, 0.14);
    background: #fff;
    padding: 10px;
}
.qr-link { margin: 6px 0 2px; }
.qr-link .input { font-size: 12.5px; text-align: center; }
/* ============================================
 * 新增题型：作答页控件样式（与设计器新增题型配套）
 * 排序 / 评分 / NPS / 多项填空 / 矩阵 / 段落说明
 * ============================================ */
.gapfill-wrap { display: flex; flex-direction: column; gap: 10px; }
.gapfill-wrap .gap-cell { display: flex; align-items: center; gap: 8px; color: var(--text-light); font-size: 14px; }
.gapfill-wrap .gap-input { flex: 1 1 auto; max-width: 420px; }

.sort-wrap { display: flex; flex-direction: column; gap: 8px; }
.sort-wrap .sort-row {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: #fff;
}
.sort-wrap .sort-no { color: var(--text-light); font-size: 13px; min-width: 22px; }
.sort-wrap .sort-txt { flex: 1 1 auto; }
.sort-wrap .sort-row .btn + .btn { margin-left: 0; }

.rating-wrap { display: flex; align-items: center; gap: 6px; }
.rating-wrap .rating-star {
    font-size: 30px; line-height: 1; color: #dcdcdc; cursor: pointer; transition: color .15s, transform .15s;
    user-select: none;
}
.rating-wrap .rating-star:hover { transform: scale(1.08); }
.rating-wrap .rating-star.selected { color: #f6b100; }
.rating-wrap .rating-value { margin-left: 10px; font-size: 13px; color: var(--text-light); }

.nps-wrap { max-width: 640px; }
.nps-scale { display: flex; gap: 6px; flex-wrap: wrap; }
.nps-btn {
    width: 44px; height: 40px; line-height: 40px; text-align: center;
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff;
    cursor: pointer; font-size: 14px; color: var(--text); user-select: none;
    transition: all .15s;
}
.nps-btn:hover { border-color: var(--primary-light); color: var(--primary); }
.nps-btn.selected { background: var(--primary); border-color: var(--primary); color: #fff; }
.nps-legend { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12px; color: var(--text-light); }

.matrix-wrap { overflow-x: auto; }
.matrix-table { width: 100%; border-collapse: collapse; min-width: 420px; }
.matrix-table th, .matrix-table td { border: 1px solid var(--border); padding: 10px; text-align: center; font-size: 13px; }
.matrix-table th { background: #f7f9fc; font-weight: 600; color: var(--text); }
.matrix-table .mx-row { text-align: left; background: #fbfcfe; font-weight: 500; }
.matrix-table .mx-cell { display: flex; align-items: center; justify-content: center; cursor: pointer; }
.matrix-table .mx-cell input { width: 16px; height: 16px; cursor: pointer; }

.para-block {
    padding: 14px 16px; background: #f7f9fc; border-left: 3px solid var(--primary-light);
    border-radius: var(--radius-sm); color: var(--text); line-height: 1.8; white-space: pre-wrap;
}