/* ==========================================================
   问卷台 · 方案 A「清透现代」
   冷白底 + 靛蓝主色 + 卡片化 + 表格化列表
   ========================================================== */

:root {
  /* 表面 */
  --bg1: #f7f9fd;
  --bg2: #f0f4fb;
  --card: #ffffff;
  --card-hover: #fafcff;
  --thead: #fbfcfe;

  /* 文字 */
  --ink: #0f172a;
  --ink2: #42506b;
  --muted: #7c8798;
  --faint: #a3adbd;

  /* 线 */
  --line: #e8edf6;
  --line2: #dde5f2;
  --line3: #cbd6e8;

  /* 语义 */
  --accent: #3056d3;
  --accent-hover: #2445b8;
  --accent-soft: #edf1fe;
  --green: #0f7b5f;
  --green-soft: #e6f5ef;
  --amber: #a06412;
  --amber-soft: #fbf1df;
  --danger: #b4472f;
  --danger-soft: #fdeeea;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;

  --sans: "PingFang SC", "HarmonyOS Sans SC", "Source Han Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Consolas, monospace;

  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 14px 30px -20px rgba(15, 23, 42, .18);
  --shadow-lg: 0 1px 2px rgba(15, 23, 42, .05), 0 24px 48px -28px rgba(15, 23, 42, .25);
  --ease: cubic-bezier(.22, 1, .36, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  background: linear-gradient(180deg, var(--bg1), var(--bg2));
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: 14px; }
::selection { background: #dbe4ff; }

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line2);
  border-radius: var(--r-sm);
  background: #fff;
  color: var(--ink);
  font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .16s var(--ease), border-color .16s var(--ease), color .16s var(--ease), box-shadow .16s var(--ease);
}
.btn:hover { background: #f8fafd; border-color: var(--line3); }
.btn:active { background: #f1f5fb; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 8px 18px -10px rgba(48, 86, 211, .9);
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn.primary:active { background: #1b379c; }

.btn.ghost { border-color: transparent; background: transparent; color: var(--ink2); }
.btn.ghost:hover { background: #f1f5fb; color: var(--ink); }

.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: #f1c9bf; }

.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

/* 行内文字动作 */
.acts { display: flex; gap: 2px; justify-content: flex-end; flex-wrap: wrap; }
.acts button, .acts a {
  border: 0;
  background: transparent;
  color: var(--ink2);
  font-size: 12.5px;
  padding: 5px 7px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .14s var(--ease), color .14s var(--ease);
}
.acts button:hover, .acts a:hover { background: var(--accent-soft); color: var(--accent-hover); }
.acts .danger:hover { background: var(--danger-soft); color: var(--danger); }
.survey-row .acts { opacity: .7; transition: opacity .16s var(--ease); }
.survey-row:hover .acts { opacity: 1; }

/* ---------- 表单 ---------- */

.field { margin-bottom: 16px; }
.field > label {
  display: block;
  margin-bottom: 7px;
  font-size: 11.5px;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 500;
}
.input, .select, .textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line2);
  border-radius: var(--r-sm);
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--line3); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(48, 86, 211, .12);
}
.textarea { min-height: 80px; resize: vertical; line-height: 1.7; }

.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink2); cursor: pointer; }
.check input { accent-color: var(--accent); }

/* ---------- 状态胶囊 ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
  background: #f1f4f9;
  color: var(--muted);
  white-space: nowrap;
}
.pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill.published { background: var(--green-soft); color: var(--green); }
.pill.draft { background: var(--amber-soft); color: var(--amber); }
.pill.closed { background: #f1f4f9; color: var(--muted); }
.pill.super { background: var(--accent-soft); color: var(--accent); }

/* ---------- 通用块 ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
}

.empty {
  padding: 64px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}
.empty strong { display: block; color: var(--ink2); font-weight: 600; font-size: 15px; margin-bottom: 6px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%) translateY(10px);
  background: #101828;
  color: #f4f7fc;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 18px 40px -18px rgba(15, 23, 42, .6);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
  z-index: 999;
  max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ==========================================================
   登录页
   ========================================================== */

.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 420px at 50% -10%, #e6ecff 0%, transparent 62%),
    linear-gradient(180deg, var(--bg1), var(--bg2));
  position: relative;
}
.login-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  padding: 34px 32px 28px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
}
.login-card h1 { margin: 0 0 6px; font-size: 23px; line-height: 1.3; letter-spacing: -.02em; font-weight: 600; }
.login-card .sub { margin: 0 0 24px; color: var(--muted); font-size: 13px; }
.login-card .btn { width: 100%; height: 42px; margin-top: 4px; font-size: 14px; border-radius: 9px; }
.login-error {
  margin: 0 0 14px;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12.5px;
  display: none;
}
.login-tip {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
}
.login-tip .tip-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 3px 0; }
.login-tip b { font-family: var(--mono); font-weight: 500; color: var(--ink2); font-size: 11px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.brand .logo {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  background: linear-gradient(145deg, #4a6ee8, #2a49c8);
  box-shadow: 0 6px 14px -6px rgba(48, 86, 211, .75);
}
.brand-text b { display: block; line-height: 1.2; }
.brand-text span {
  display: block;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .22em;
  color: var(--faint);
  margin-top: 3px;
}
.login-card .brand { margin-bottom: 26px; }

/* ==========================================================
   后台布局
   ========================================================== */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex: 0 0 240px;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 22px 14px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand { padding: 0 8px 22px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 11px;
  border-radius: 9px;
  color: var(--ink2);
  font-size: 13.5px;
  white-space: nowrap;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.nav a svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.6; fill: none; opacity: .72; flex: none; }
.nav a:hover { background: #f4f7fd; color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent-hover); font-weight: 600; }
.nav a.active svg { opacity: 1; }
.nav-label {
  font-size: 10.5px;
  letter-spacing: .14em;
  color: var(--faint);
  padding: 20px 12px 8px;
}

.sidebar .foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; }
.user-box { display: flex; align-items: center; gap: 9px; padding: 4px 6px 12px; }
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 600;
  flex: none;
}
.user-meta { min-width: 0; }
.user-meta .name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta .role { font-size: 11px; color: var(--faint); }
.foot-act { display: flex; gap: 6px; }
.foot-act .btn { flex: 1; }

.main { flex: 1; min-width: 0; padding: 30px 38px 54px; max-width: 1180px; }

.crumb { font-size: 11.5px; color: var(--faint); letter-spacing: .06em; margin-bottom: 10px; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}
.page-head h2 { margin: 0 0 6px; font-size: 29px; line-height: 1.25; letter-spacing: -.025em; font-weight: 600; }
.page-head p { margin: 0; color: var(--muted); font-size: 13px; }
.head-actions { display: flex; gap: 8px; align-items: center; padding-top: 4px; }

/* ---------- 指标卡 ---------- */

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px 18px 15px;
  box-shadow: var(--shadow);
}
.stat .k { font-size: 11.5px; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }
.stat .v {
  font-size: 29px;
  line-height: 1;
  font-weight: 600;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.stat .v small { font-size: 11.5px; font-weight: 400; color: var(--faint); margin-left: 4px; letter-spacing: 0; }
.delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  font-size: 11px;
  color: var(--green);
  background: var(--green-soft);
  padding: 2px 8px;
  border-radius: 20px;
}
.delta.gray { color: var(--muted); background: #f3f6fb; }
.delta.blue { color: var(--accent); background: var(--accent-soft); }

/* ---------- 列表 ---------- */

.list-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.seg { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  height: 30px; padding: 0 14px; border: 0; background: transparent; border-radius: 7px;
  font-size: 12.5px; color: var(--ink2); cursor: pointer; transition: background .14s var(--ease), color .14s var(--ease);
}
.seg button:hover { background: #f5f8fd; }
.seg button.on { background: var(--accent-soft); color: var(--accent-hover); font-weight: 600; }

.survey-list {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.row-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px 112px 272px;
  gap: 16px;
  padding: 12px 20px;
  background: var(--thead);
  border-bottom: 1px solid var(--line);
  font-size: 10.5px;
  letter-spacing: .12em;
  color: var(--faint);
}
.survey-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px 112px 272px;
  gap: 16px;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
  transition: background .16s var(--ease);
}
.survey-row:last-child { border-bottom: none; }
.survey-row:hover { background: var(--card-hover); }
.survey-title { display: flex; align-items: center; gap: 9px; margin-bottom: 4px; }
.survey-title .name {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.survey-sub { font-size: 12px; color: var(--faint); display: flex; gap: 14px; flex-wrap: wrap; }
.survey-num { font-size: 16px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.survey-num span { display: block; font-size: 10.5px; font-weight: 400; color: var(--faint); letter-spacing: .06em; margin-top: 1px; }

/* ---------- 编辑器 ---------- */

.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }

.q-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.q-card.plain { padding: 20px 20px 6px; }

.q-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.q-index {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 600;
  flex: none;
}
.q-type {
  height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 6px;
  background: #f4f7fc;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .06em;
  white-space: nowrap;
}
.q-head .grow { flex: 1; }
.q-head .btn.sm { height: 26px; padding: 0 8px; font-size: 12px; }
.q-head .btn.danger { border-color: transparent; background: transparent; color: var(--faint); }
.q-head .btn.danger:hover { color: var(--danger); background: var(--danger-soft); border-color: transparent; }

.q-card > .input { font-size: 15px; font-weight: 600; letter-spacing: -.01em; padding: 9px 11px; }

.opt-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.opt-row .mark { width: 14px; text-align: center; color: var(--faint); font-size: 11px; flex: none; }
.opt-row .input { flex: 1; padding: 7px 10px; }
.opt-row .btn.ghost { color: var(--faint); flex: none; }
.opt-row .btn.ghost:hover { color: var(--danger); background: var(--danger-soft); }

.q-tools { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.q-tools .hint { color: var(--faint); font-size: 11.5px; }

.add-bar { display: flex; gap: 8px; flex-wrap: wrap; padding: 2px 0 4px; }
.add-bar .btn { border-style: dashed; border-color: var(--line3); color: var(--ink2); background: transparent; }
.add-bar .btn:hover { border-style: solid; border-color: var(--accent); color: var(--accent); background: #fff; }

.editor-side { position: sticky; top: 28px; }
.side-card { padding: 18px; margin-bottom: 14px; background: #fff; }
.side-card h4 {
  margin: 0 0 14px;
  font-size: 11px;
  letter-spacing: .12em;
  color: var(--muted);
  font-weight: 500;
}
.side-field { margin-bottom: 14px; }
.side-field label { display: block; font-size: 11px; color: var(--muted); letter-spacing: .06em; margin-bottom: 6px; }
.side-hint { margin: 0; padding: 0; list-style: none; color: var(--muted); font-size: 12px; line-height: 1.95; }
.side-hint li { position: relative; padding-left: 12px; }
.side-hint li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--line3);
}

/* ---------- 统计 ---------- */

.result-q {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 18px 20px 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  max-width: 900px;
}
.result-q h4 {
  margin: 0 0 16px;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -.005em;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.result-q h4 .qn {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  flex: none;
  align-self: center;
}
.result-q h4 .meta { color: var(--muted); font-weight: 400; font-size: 11.5px; margin-left: auto; }

.bar-row {
  display: grid;
  grid-template-columns: 168px 1fr 84px;
  gap: 14px;
  align-items: center;
  margin-bottom: 10px;
  font-size: 13px;
}
.bar-label { color: var(--ink2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 8px; background: #eef2f9; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .5s var(--ease); }
.bar-val { text-align: right; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.text-answers { display: flex; flex-direction: column; gap: 8px; max-height: 340px; overflow: auto; }
.text-answer {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 13px;
  color: var(--ink2);
  background: #fcfdff;
  display: flex;
  gap: 12px;
  align-items: baseline;
}
.text-answer .t { font-size: 11px; color: var(--faint); flex: none; order: -1; min-width: 20px; font-variant-numeric: tabular-nums; }

/* ---------- 表格 ---------- */

.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 13px 18px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.table th { background: var(--thead); color: var(--faint); font-weight: 500; font-size: 10.5px; letter-spacing: .12em; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--card-hover); }
.table td .mono { font-family: var(--mono); font-size: 12.5px; color: var(--ink2); }

/* ---------- 弹窗 ---------- */

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .38);
  backdrop-filter: blur(3px);
  display: none;
  place-items: center;
  z-index: 100;
  padding: 20px;
}
.modal-mask.show { display: grid; }
.modal {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  animation: modalIn .22s var(--ease);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.modal h3 { margin: 0 0 16px; font-size: 17px; letter-spacing: -.01em; }
.modal p { color: var(--ink2); }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }

/* ---------- 响应式 ---------- */

@media (max-width: 1080px) {
  .row-head, .survey-row { grid-template-columns: minmax(0, 1fr) 84px 150px; }
  .row-head > div:nth-child(3), .survey-row > div:nth-child(3) { display: none; }
  .main { padding: 24px 24px 48px; }
}

@media (max-width: 900px) {
  .editor-grid { grid-template-columns: 1fr; }
  .editor-side { position: static; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex: none;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-right: none;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    scrollbar-width: none;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar .brand { padding: 0; margin: 0; flex: none; }
  .sidebar .brand .logo { width: 26px; height: 26px; border-radius: 8px; font-size: 13px; }
  .brand-text { display: none; }
  .nav { flex-direction: row; gap: 2px; flex: none; }
  .nav-label { display: none; }
  .nav a { height: 34px; padding: 0 10px; }
  .sidebar .foot { margin: 0 0 0 auto; border: none; padding: 0; display: flex; align-items: center; gap: 6px; flex: none; }
  .user-box { padding: 0; }
  .user-meta { display: none; }
  .foot-act .btn { flex: none; height: 28px; padding: 0 9px; font-size: 12px; }
  .page-head { flex-direction: column; gap: 14px; }
  .page-head h2 { font-size: 23px; }
  .row-head { display: none; }
  .survey-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
    padding: 15px 16px;
    align-items: center;
  }
  .survey-main { grid-column: 1 / -1; }
  .survey-title .name { white-space: normal; }
  .survey-sub { gap: 10px; }
  .survey-num { grid-column: 1; font-size: 15px; }
  .survey-num span { display: inline; margin-left: 4px; }
  .survey-row > div:nth-child(3) { display: block; grid-column: 2; justify-self: end; }
  .acts {
    grid-column: 1 / -1;
    justify-content: flex-start;
    opacity: 1;
    margin-top: 4px;
    padding-top: 9px;
    border-top: 1px solid var(--line);
  }
  .bar-row { grid-template-columns: 104px 1fr 64px; gap: 10px; }
}
