/* ============================================================
   表单收集系统 —— 设计系统
   主色：蓝色 #2563eb；中文优先字体；移动端优先响应式
   ============================================================ */

:root {
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-light: #eff6ff;
  --brand-soft: #dbeafe;

  --ink: #111827;
  --ink-2: #374151;
  --ink-3: #6b7280;
  --ink-4: #9ca3af;

  --line: #e5e7eb;
  --line-2: #f3f4f6;
  --soft: #f9fafb;
  --bg: #f3f4f6;
  --white: #ffffff;

  --success: #059669;
  --success-soft: #ecfdf5;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --info: #0891b2;

  --radius: 10px;
  --radius-lg: 14px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.06);
  --shadow: 0 4px 14px rgba(17, 24, 39, 0.08);
  --shadow-lg: 0 12px 32px rgba(17, 24, 39, 0.12);

  --header-h: 56px;
  --sidebar-w: 232px;
  --font: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
  line-height: 1.35;
}

/* ------------------------------ 布局 ------------------------------ */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar .logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 15.5px;
  color: var(--ink);
  white-space: nowrap;
}

.topbar .logo .mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--brand), #60a5fa);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
}

.topbar .spacer {
  flex: 1;
}

.topbar .user {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-2);
  font-size: 13px;
}

.topbar .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand-light);
  color: var(--brand);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 12.5px;
}

.layout {
  flex: 1;
  display: flex;
  min-height: 0;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--line);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}

.sidebar .nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: 13.5px;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.sidebar .nav-item:hover {
  background: var(--soft);
  text-decoration: none;
}

.sidebar .nav-item.active {
  background: var(--brand-light);
  color: var(--brand);
  font-weight: 600;
}

.sidebar .nav-group {
  font-size: 11.5px;
  color: var(--ink-4);
  padding: 14px 12px 5px;
  letter-spacing: 0.4px;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 20px 22px 40px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.page-head h1 {
  font-size: 20px;
}

.page-head .desc {
  color: var(--ink-3);
  font-size: 13px;
  margin-top: 3px;
}

.page-head .actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ------------------------------ 卡片 ------------------------------ */
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.card + .card {
  margin-top: 14px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.card-head h2,
.card-head h3 {
  font-size: 15px;
}

.card-head .actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 12px;
}

.stat {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.stat .label {
  font-size: 12.5px;
  color: var(--ink-3);
}

.stat .value {
  font-size: 24px;
  font-weight: 700;
  color: var(--brand);
  line-height: 1.3;
}

.stat .sub {
  font-size: 12px;
  color: var(--ink-4);
}

/* ------------------------------ 按钮 ------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink-2);
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.14s, border-color 0.14s, color 0.14s;
}

.btn:hover {
  background: var(--soft);
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn-primary:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

.btn-danger {
  color: var(--danger);
  border-color: #fecaca;
  background: var(--danger-soft);
}
.btn-danger:hover {
  background: #fee2e2;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
}
.btn-ghost:hover {
  background: var(--line-2);
}

.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12.5px;
}

.btn-lg {
  height: 42px;
  padding: 0 22px;
  font-size: 15px;
}

.btn-block {
  width: 100%;
}

/* ------------------------------ 表单 ------------------------------ */
.field {
  margin-bottom: 14px;
}

.field > label {
  display: block;
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 5px;
  font-weight: 500;
}

.field .hint {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 4px;
}

.field .error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 4px;
}

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--ink);
  background: var(--white);
  outline: none;
  transition: border-color 0.14s, box-shadow 0.14s;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  background: var(--soft);
  color: var(--ink-3);
  cursor: not-allowed;
}

.textarea {
  min-height: 84px;
  resize: vertical;
}

.input-error {
  border-color: var(--danger);
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.row > * {
  flex: 1;
  min-width: 0;
}

/* 开关 */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-2);
  user-select: none;
}

.switch input {
  display: none;
}

.switch .track {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: #d1d5db;
  position: relative;
  transition: background 0.15s;
  flex-shrink: 0;
}

.switch .track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
  box-shadow: var(--shadow-sm);
}

.switch input:checked + .track {
  background: var(--brand);
}

.switch input:checked + .track::after {
  transform: translateX(16px);
}

/* 单选/多选按钮组 */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-radio {
  padding: 4px 11px;
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
  background: var(--white);
}

.chip-radio.active {
  border-color: var(--brand);
  background: var(--brand-light);
  color: var(--brand);
  font-weight: 600;
}

/* ------------------------------ 表格 ------------------------------ */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data th,
table.data td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

table.data th {
  background: var(--soft);
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
}

table.data tbody tr:hover {
  background: #fcfdff;
}

table.data tbody tr:last-child td {
  border-bottom: none;
}

table.data td.num,
table.data th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------ 标签 ------------------------------ */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 12px;
  background: var(--brand-light);
  color: var(--brand);
  white-space: nowrap;
}

.tag-gray {
  background: var(--line-2);
  color: var(--ink-3);
}
.tag-green {
  background: var(--success-soft);
  color: var(--success);
}
.tag-amber {
  background: var(--warn-soft);
  color: var(--warn);
}
.tag-red {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ------------------------------ 问卷列表卡片 ------------------------------ */
.survey-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(276px, 1fr));
  gap: 14px;
}

.survey-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow 0.15s, transform 0.15s;
}

.survey-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.survey-card h3 {
  font-size: 15px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.survey-card .meta {
  font-size: 12px;
  color: var(--ink-3);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.survey-card .foot {
  margin-top: auto;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 4px;
  border-top: 1px dashed var(--line);
}

/* ------------------------------ 模态框 ------------------------------ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 20px;
}

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-head {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  font-weight: 600;
  font-size: 15px;
}

.modal-head .close {
  margin-left: auto;
  border: none;
  background: none;
  font-size: 20px;
  color: var(--ink-4);
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
}

.modal-foot {
  padding: 13px 18px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  background: var(--soft);
}

/* ------------------------------ 提示 ------------------------------ */
.toast-wrap {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  background: var(--ink);
  color: #fff;
  padding: 9px 16px;
  border-radius: 20px;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  max-width: 80vw;
  animation: toast-in 0.18s ease-out;
}

.toast.success {
  background: var(--success);
}
.toast.error {
  background: var(--danger);
}
.toast.warn {
  background: var(--warn);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.empty {
  text-align: center;
  color: var(--ink-3);
  padding: 46px 20px;
  font-size: 13.5px;
}

.empty .big {
  font-size: 34px;
  margin-bottom: 10px;
  opacity: 0.4;
}

.loading {
  text-align: center;
  color: var(--ink-3);
  padding: 40px;
  font-size: 13.5px;
}

/* ------------------------------ 登录页 ------------------------------ */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #eff6ff 0%, #f3f4f6 55%, #eef2ff 100%);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 384px;
  background: var(--white);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 30px 28px 26px;
}

.login-card .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.login-card .brand .mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), #60a5fa);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 18px;
}

.login-card h1 {
  font-size: 19px;
}

.login-card .sub {
  color: var(--ink-3);
  font-size: 13px;
  margin: 0 0 20px;
}

.captcha-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.captcha-row .input {
  flex: 1;
}

.captcha-row .captcha-img {
  width: 108px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--soft);
  flex-shrink: 0;
}

/* ------------------------------ 填写端 ------------------------------ */
.fill-page {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 0 96px;
}

.fill-hero {
  background: linear-gradient(135deg, var(--brand) 0%, #3b82f6 60%, #60a5fa 100%);
  color: #fff;
  padding: 26px 22px 30px;
  border-radius: 0 0 18px 18px;
}

.fill-hero h1 {
  font-size: 20px;
  margin-bottom: 6px;
}

.fill-hero p {
  margin: 0;
  font-size: 13px;
  opacity: 0.92;
  white-space: pre-wrap;
}

.fill-body {
  padding: 16px 16px 0;
}

.progress-bar {
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 14px;
}

.progress-bar span {
  display: block;
  height: 100%;
  background: var(--brand);
  transition: width 0.25s;
}

.q-item {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
}

.q-item.invalid {
  border-color: #fecaca;
  background: #fffbfb;
}

.q-item .q-title {
  font-size: 14.5px;
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  gap: 6px;
  align-items: baseline;
}

.q-item .q-title .idx {
  color: var(--ink-3);
  font-weight: 500;
  font-size: 13px;
}

.q-item .q-title .req {
  color: var(--danger);
}

.q-item .q-desc {
  font-size: 12.5px;
  color: var(--ink-3);
  margin-bottom: 10px;
  white-space: pre-wrap;
}

.q-item .q-body {
  margin-top: 8px;
}

.q-item .q-error {
  color: var(--danger);
  font-size: 12.5px;
  margin-top: 6px;
}

.q-item .q-tip {
  color: var(--ink-3);
  font-size: 12px;
  margin-top: 6px;
}

.q-item.is-derived input,
.q-item.is-derived select {
  background: #f0f9ff;
  border-color: #bae6fd;
  color: #0369a1;
}

.opt-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.opt {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  cursor: pointer;
  font-size: 13.5px;
  background: var(--white);
  transition: border-color 0.12s, background 0.12s;
}

.opt:hover {
  border-color: var(--brand-soft);
  background: #fbfdff;
}

.opt.checked {
  border-color: var(--brand);
  background: var(--brand-light);
}

.opt input {
  margin: 0;
  accent-color: var(--brand);
}

.opt.none {
  border-style: dashed;
}

.matrix {
  overflow-x: auto;
}

table.matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 380px;
}

table.matrix-table th,
table.matrix-table td {
  border: 1px solid var(--line);
  padding: 8px 9px;
  text-align: center;
}

table.matrix-table th:first-child,
table.matrix-table td:first-child {
  text-align: left;
  background: var(--soft);
  font-weight: 500;
  min-width: 104px;
}

.rating-stars {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.rating-stars .star {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  cursor: pointer;
  font-size: 15px;
  color: var(--ink-3);
  display: grid;
  place-items: center;
}

.rating-stars .star.on {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #d97706;
}

.nps-scale {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.nps-scale .nps-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-2);
}

.nps-scale .nps-btn.on {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}

.nps-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--ink-4);
  margin-top: 4px;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slider-row input[type="range"] {
  flex: 1;
  accent-color: var(--brand);
}

.slider-row .val {
  min-width: 62px;
  text-align: right;
  font-weight: 600;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}

.submit-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(6px);
  border-top: 1px solid var(--line);
  padding: 11px 16px calc(11px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  z-index: 30;
}

.submit-bar .inner {
  width: 100%;
  max-width: 648px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.submit-bar .tip {
  font-size: 12px;
  color: var(--ink-3);
}

.success-panel {
  text-align: center;
  padding: 46px 22px;
}

.success-panel .icon {
  width: 62px;
  height: 62px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--success);
  display: grid;
  place-items: center;
  font-size: 30px;
}

/* ------------------------------ 设计器 ------------------------------ */
.designer {
  display: grid;
  grid-template-columns: 236px 1fr 316px;
  gap: 0;
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

.designer .pane {
  background: var(--white);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.designer .pane.right {
  border-right: none;
  border-left: 1px solid var(--line);
}

.pane-head {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--soft);
}

.pane-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  min-height: 0;
}

.type-group-title {
  font-size: 11.5px;
  color: var(--ink-4);
  margin: 12px 4px 6px;
}

.type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.type-btn {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--white);
  padding: 8px 6px;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  line-height: 1.35;
}

.type-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-light);
}

.canvas-wrap {
  overflow-y: auto;
  padding: 16px;
  background: var(--bg);
  min-height: 0;
}

.canvas {
  max-width: 660px;
  margin: 0 auto;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  min-height: 320px;
}

.canvas-hero {
  border-bottom: 1px dashed var(--line);
  padding-bottom: 14px;
  margin-bottom: 14px;
}

.canvas-hero h2 {
  font-size: 18px;
}

.canvas-hero p {
  color: var(--ink-3);
  font-size: 13px;
  margin: 6px 0 0;
  white-space: pre-wrap;
}

.q-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 13px;
  margin-bottom: 10px;
  background: var(--white);
  cursor: pointer;
  position: relative;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.q-block:hover {
  border-color: var(--brand-soft);
}

.q-block.selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.q-block.dragging {
  opacity: 0.45;
}

.q-block.drop-target {
  border-top: 3px solid var(--brand);
}

.q-block .q-head {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-size: 14px;
  font-weight: 600;
}

.q-block .q-head .idx {
  color: var(--ink-3);
  font-weight: 500;
  font-size: 12.5px;
}

.q-block .q-head .req {
  color: var(--danger);
}

.q-block .q-meta {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 5px;
}

.q-block .q-tools {
  position: absolute;
  top: 8px;
  right: 8px;
  display: none;
  gap: 3px;
}

.q-block:hover .q-tools,
.q-block.selected .q-tools {
  display: flex;
}

.q-block .q-tools button {
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  color: var(--ink-3);
  display: grid;
  place-items: center;
}

.q-block .q-tools button:hover {
  color: var(--brand);
  border-color: var(--brand);
}

.q-block .badge-row {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.canvas-empty {
  text-align: center;
  color: var(--ink-3);
  padding: 56px 20px;
  font-size: 13.5px;
}

.prop-section {
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.prop-section:first-child {
  padding-top: 0;
}

.prop-section h4 {
  font-size: 12.5px;
  color: var(--ink-3);
  margin-bottom: 9px;
  font-weight: 600;
}

.opt-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.opt-row .drag-handle {
  color: var(--ink-4);
  cursor: grab;
  font-size: 13px;
}

.opt-row .input {
  flex: 1;
}

.opt-row .del {
  border: none;
  background: none;
  color: var(--ink-4);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}

.opt-row .del:hover {
  color: var(--danger);
}

.rule-row {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-bottom: 8px;
  background: var(--soft);
  font-size: 12.5px;
}

.rule-row .rule-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 7px;
}

.rule-row .rule-head .tag {
  font-size: 11.5px;
}

.rule-row .rule-head .del {
  margin-left: auto;
  border: none;
  background: none;
  color: var(--ink-4);
  cursor: pointer;
}

.rule-row .rule-head .del:hover {
  color: var(--danger);
}

.preview-toggle {
  display: flex;
  gap: 4px;
  background: var(--line-2);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.preview-toggle button {
  border: none;
  background: none;
  padding: 4px 11px;
  font-size: 12.5px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--ink-2);
  font-family: inherit;
}

.preview-toggle button.active {
  background: var(--white);
  color: var(--brand);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.canvas.mobile {
  max-width: 390px;
}

/* ------------------------------ 统计图表 ------------------------------ */
.chart-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
  font-size: 13px;
}

.chart-row .name {
  width: 130px;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-2);
}

.chart-row .track {
  flex: 1;
  height: 16px;
  background: var(--line-2);
  border-radius: 4px;
  overflow: hidden;
  min-width: 60px;
}

.chart-row .track span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand), #60a5fa);
  border-radius: 4px;
}

.chart-row .val {
  width: 92px;
  text-align: right;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.pie-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.pie-legend {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  min-width: 150px;
  flex: 1;
}

.pie-legend .item {
  display: flex;
  align-items: center;
  gap: 7px;
}

.pie-legend .dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.pie-legend .pct {
  margin-left: auto;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.word-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.word-cloud .w {
  background: var(--brand-light);
  color: var(--brand);
  border-radius: 14px;
  padding: 3px 11px;
  font-size: 12.5px;
}

.word-cloud .w b {
  margin-left: 5px;
  color: var(--brand-dark);
}

.trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 138px;
  padding: 10px 4px 0;
  overflow-x: auto;
}

.trend-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  min-width: 30px;
  font-size: 10.5px;
  color: var(--ink-4);
  gap: 3px;
}

.trend-col .bar {
  width: 20px;
  background: var(--brand);
  opacity: 0.82;
  border-radius: 3px 3px 0 0;
  min-height: 3px;
}

.q-stat {
  border-top: 1px solid var(--line);
  padding: 16px 0;
}

.q-stat:first-child {
  border-top: none;
  padding-top: 0;
}

.q-stat .q-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.q-stat .q-head h3 {
  font-size: 14.5px;
}

.q-stat .q-meta {
  font-size: 12px;
  color: var(--ink-3);
  margin-bottom: 10px;
}

/* ------------------------------ 工具类 ------------------------------ */
.flex {
  display: flex;
}
.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.flex-center {
  display: flex;
  align-items: center;
  gap: 8px;
}
.flex-wrap {
  flex-wrap: wrap;
}
.gap-4 {
  gap: 4px;
}
.gap-8 {
  gap: 8px;
}
.gap-12 {
  gap: 12px;
}
.mt-8 {
  margin-top: 8px;
}
.mt-12 {
  margin-top: 12px;
}
.mt-16 {
  margin-top: 16px;
}
.mb-8 {
  margin-bottom: 8px;
}
.mb-12 {
  margin-bottom: 12px;
}
.text-sm {
  font-size: 12.5px;
}
.text-muted {
  color: var(--ink-3);
}
.text-danger {
  color: var(--danger);
}
.text-success {
  color: var(--success);
}
.mono {
  font-variant-numeric: tabular-nums;
}
.nowrap {
  white-space: nowrap;
}
.hidden {
  display: none !important;
}
.w-full {
  width: 100%;
}
.link-btn {
  border: none;
  background: none;
  color: var(--brand);
  cursor: pointer;
  font-size: 12.5px;
  font-family: inherit;
  padding: 0;
}
.link-btn:hover {
  text-decoration: underline;
}

/* ------------------------------ 响应式 ------------------------------ */
@media (max-width: 1080px) {
  .designer {
    grid-template-columns: 200px 1fr 288px;
  }
}

@media (max-width: 900px) {
  .designer {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }
  .designer .pane {
    border-right: none;
    border-bottom: 1px solid var(--line);
    max-height: 46vh;
  }
  .designer .pane.right {
    border-left: none;
  }
  .layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--line);
    flex-direction: row;
    overflow-x: auto;
    padding: 8px;
    gap: 6px;
  }
  .sidebar .nav-group {
    display: none;
  }
  .sidebar .nav-item {
    width: auto;
    white-space: nowrap;
  }
  .main {
    padding: 14px 14px 34px;
  }
}

@media (max-width: 560px) {
  .fill-hero {
    border-radius: 0;
    padding: 22px 16px 26px;
  }
  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }
  .modal {
    max-width: 100%;
  }
  .chart-row .name {
    width: 84px;
  }
}

@media print {
  .topbar,
  .sidebar,
  .page-head .actions,
  .no-print {
    display: none !important;
  }
  body {
    background: #fff;
  }
  .main {
    padding: 0;
  }
  .card {
    border: none;
    box-shadow: none;
    padding: 0;
  }
}
