/* ============================================================
   Design tokens. Every color/spacing/radius value used below
   is pulled from here — change the palette in one place instead
   of hunting through fifteen section files (which never touch
   these values directly, only shared class names).
   ============================================================ */
:root {
  /* DevFest 2026 品牌色板（Brand Guide「Colors」页）：核心色 Blue 500 / Green 500 /
     Yellow 600 / Red 500，粉彩用作浅底，灰阶只有 Off White 和 Black 02——中间灰都用
     Black 02 的透明度。深一档的 *-dark 只用在小号文字上，保证对比度。 */
  --color-primary: #4285f4;
  --color-primary-dark: #1967d2;
  --color-primary-soft: #e3f5fa;
  --color-primary-soft-strong: #c3ecf6;

  --color-success: #1e8e3e;
  --color-success-soft: #ccf6c5;
  --color-warning: #b06000;
  --color-warning-soft: #ffe7a5;
  --color-danger: #d93025;
  --color-danger-soft: #f8d8d8;

  --brand-blue: #4285f4;
  --brand-red: #ea4335;
  --brand-yellow: #f9ab00;
  --brand-green: #34a853;

  --color-text: #1e1e1e;
  --color-text-secondary: rgba(30, 30, 30, 0.66);
  --color-text-tertiary: rgba(30, 30, 30, 0.42);

  --color-border: rgba(30, 30, 30, 0.1);
  --color-border-strong: rgba(30, 30, 30, 0.22);

  --color-bg: #f0f0f0;
  --color-surface: #ffffff;

  /* 侧边栏：KV 的深色底 */
  --color-sidebar-bg: #1e1e1e;
  --color-sidebar-bg-elevated: #1e1e1e;
  --color-sidebar-text: rgba(255, 255, 255, 0.78);
  --color-sidebar-text-dim: rgba(255, 255, 255, 0.42);
  --color-sidebar-border: rgba(255, 255, 255, 0.1);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(30, 30, 30, 0.04);
  --shadow-md: 0 4px 16px rgba(30, 30, 30, 0.06);
  --shadow-lg: 0 12px 32px rgba(30, 30, 30, 0.14);

  --sidebar-width: 232px;
  --topbar-height: 64px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--color-primary-soft-strong); color: var(--color-primary-dark); }

/* thin, unobtrusive scrollbars everywhere — the default chunky gray bars
   are one of the fastest visual "this is a prototype" tells. */
* { scrollbar-width: thin; scrollbar-color: var(--color-border-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: var(--radius-pill); }
*::-webkit-scrollbar-track { background: transparent; }

h1, h2, h3 { margin: 0; }

/* ---- form controls ---- */

button {
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  padding: 9px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  background: var(--color-primary);
  color: #fff;
  transition: background-color 0.12s ease, border-color 0.12s ease, opacity 0.12s ease, transform 0.05s ease;
  letter-spacing: 0.1px;
}
button:hover { background: var(--color-primary-dark); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

button.secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border-strong);
}
button.secondary:hover { background: var(--color-bg); border-color: var(--color-text); }

button.danger { background: var(--color-danger); }
button.danger:hover { background: #b3261e; }
button.danger.secondary { background: var(--color-surface); color: var(--color-danger); border-color: rgba(217, 48, 37, 0.35); }
button.danger.secondary:hover { background: var(--color-danger-soft); }

button.small { padding: 5px 14px; font-size: 12px; border-radius: var(--radius-pill); }

input, select, textarea {
  font-size: 14px;
  font-family: inherit;
  padding: 8px 11px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
input::placeholder, textarea::placeholder { color: var(--color-text-tertiary); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}
input:disabled { background: var(--color-bg); color: var(--color-text-tertiary); }

/* ============================================================
   Login
   ============================================================ */

#login-view {
  max-width: 360px;
  width: calc(100% - 32px);
  margin: 0 auto;
  position: relative;
  top: 14vh;
  background: var(--color-surface);
  padding: 40px 36px 32px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}

/* { DevFest } 字标：黄色花括号 + 粗体字，对应 KV 里的锁定组合 */
.brand-wordmark { display: inline-flex; align-items: center; gap: 4px; line-height: 1; }
.brand-wordmark .brace { color: var(--brand-yellow); font-weight: 300; }
.brand-wordmark .word { font-weight: 800; letter-spacing: -0.02em; }
.login-wordmark { font-size: 30px; color: var(--color-text); }
.login-wordmark .brace { font-size: 36px; }

/* KV 里长短错落的四色胶囊 */
.brand-stripe { display: flex; gap: 5px; }
.brand-stripe i { display: block; height: 6px; border-radius: var(--radius-pill); }
.brand-stripe i:nth-child(1) { width: 34px; background: var(--brand-blue); }
.brand-stripe i:nth-child(2) { width: 14px; background: var(--brand-red); }
.brand-stripe i:nth-child(3) { width: 24px; background: var(--brand-yellow); }
.brand-stripe i:nth-child(4) { width: 10px; background: var(--brand-green); }

.login-heading { font-size: 18px; font-weight: 700; color: var(--color-text); }
.login-subheading { font-size: 13px; color: var(--color-text-secondary); margin-top: 1px; }

.login-field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin: 8px 0 -4px;
}

#login-view input { padding: 10px 16px; border-radius: var(--radius-pill); }
#login-view button { padding: 11px 18px; margin-top: 4px; }

#login-error { color: var(--color-danger); font-size: 13px; min-height: 16px; }

/* 图形验证码：输入框 + 右侧图片（点击换一张） */
.captcha-row { display: flex; align-items: center; gap: 10px; }
.captcha-row input { flex: 1; min-width: 0; letter-spacing: 2px; text-transform: uppercase; }
.captcha-img {
  flex-shrink: 0;
  width: 120px;
  height: 40px;
  border-radius: var(--radius-md, 8px);
  border: 1px solid var(--color-border);
  background: var(--color-surface-muted, #f1f3f4);
  cursor: pointer;
}

.login-footnote {
  text-align: center;
  font-size: 12px;
  color: var(--color-text-tertiary);
  margin-top: 6px;
}

/* ============================================================
   App shell: dark sidebar + topbar + content
   ============================================================ */

.app-shell {
  display: none;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-sidebar-bg);
  padding: 20px 14px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px 10px 22px;
}

.sidebar-wordmark { font-size: 20px; color: #fff; }
.sidebar-wordmark .brace { font-size: 24px; }
.sidebar-subtitle { font-size: 11.5px; color: var(--color-sidebar-text-dim); line-height: 1.3; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-group { margin-bottom: 14px; }
.nav-group-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-sidebar-text-dim);
  padding: 0 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--color-sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  padding: 9px 12px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.1px;
}

.nav-item svg { flex-shrink: 0; opacity: 0.85; }

.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-item:hover svg { opacity: 1; }

.nav-item.active {
  background: #ffffff;
  color: var(--color-text);
  font-weight: 700;
}
.nav-item.active svg { opacity: 1; color: var(--brand-blue); }

/* 二级 tab（一个 view 里放两个子页面用，比如"异常数据"下的未匹配登录/支付错误日志） */
.sub-tabs { display: flex; gap: 6px; margin-bottom: 18px; border-bottom: 1px solid var(--color-border); }
.sub-tab-item {
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 4px;
  margin-right: 14px;
  border-radius: 0;
  position: relative;
  bottom: -1px;
  border-bottom: 2px solid transparent;
}
.sub-tab-item:hover { background: transparent; color: var(--color-text); }
.sub-tab-item.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

.sidebar-footer {
  border-top: 1px solid var(--color-sidebar-border);
  margin-top: 10px;
  padding-top: 12px;
}

.sidebar-footer button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  color: var(--color-sidebar-text);
  border: 1px solid var(--color-sidebar-border);
  font-weight: 500;
}
.sidebar-footer button:hover { background: rgba(255, 255, 255, 0.06); color: #fff; border-color: rgba(255, 255, 255, 0.18); }

/* ---- main column: topbar + scrolling content ---- */

.main-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-height);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(240, 240, 240, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}

.topbar-eyebrow { font-size: 11px; color: var(--color-text-tertiary); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.topbar-title { font-size: 17px; font-weight: 700; color: var(--color-text); line-height: 1.3; }

.topbar-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text);
  background: var(--color-primary-soft-strong);
  border: 1.5px solid var(--color-text);
  padding: 5px 12px;
  border-radius: var(--radius-pill);
}

.content {
  flex: 1;
  min-width: 0;
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
  padding: 26px 28px 72px;
}

.view-title {
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--color-text);
}

/* ============================================================
   Shared content patterns (cards, tables, stat tiles, badges)
   ============================================================ */

.stats { display: flex; gap: 14px; flex-wrap: wrap; }
.stat-tile {
  flex: 1;
  min-width: 150px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
/* 统计卡顶部一条品牌色，按顺序轮换蓝/红/黄/绿 */
.stat-tile::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 4px;
  background: var(--brand-blue);
}
.stat-tile:nth-child(4n+2)::before { background: var(--brand-red); }
.stat-tile:nth-child(4n+3)::before { background: var(--brand-yellow); }
.stat-tile:nth-child(4n+4)::before { background: var(--brand-green); }
.stat-tile .value { font-size: 27px; font-weight: 800; color: var(--color-text); letter-spacing: -0.02em; }
.stat-tile .label { font-size: 12.5px; color: var(--color-text-secondary); margin-top: 5px; font-weight: 500; }

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.card h2 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
}

/* "one entity per card" header — a title + status badge on the left, actions
   on the right. Used by anything that lists editable records inside cards
   (currently 抽奖管理's round cards; any future section with the same shape
   — one card per record, actions top-right — should reuse this rather than
   hand-rolling flex spacing again). */
.entity-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.entity-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.entity-title h3 { margin: 0; font-size: 16px; font-weight: 700; color: var(--color-text); }
.entity-meta { font-size: 13px; color: var(--color-text-secondary); margin-top: 4px; }
.entity-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* A labeled sub-region inside a card, separated by a rule — for cards that
   bundle a record's config + related sub-lists (e.g. a lottery round's own
   fields, its winner list, and its reserved list) instead of splitting each
   into its own card. */
.subsection { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--color-border); }
.subsection-label { font-size: 12.5px; font-weight: 700; color: var(--color-text); margin-bottom: 8px; }
.subsection-hint { font-size: 12.5px; color: var(--color-text-secondary); margin-bottom: 10px; line-height: 1.6; }

/* A bordered list of rows — the "table" shape for data too irregular for
   <table> (variable badges, trailing action buttons) to line up cleanly in
   columns. Row shape: name, secondary meta, flexible spacer, badges, trailing
   action — the spacer is what pins the action to the right regardless of
   whether badges are present. */
.mini-list { border: 1px solid var(--color-border); border-radius: var(--radius-md); overflow: hidden; }
.mini-list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--color-border);
}
.mini-list-row:last-child { border-bottom: none; }
.mini-list-row:hover { background: var(--color-bg); }
.mini-list-primary { font-weight: 600; color: var(--color-text); white-space: nowrap; }
.mini-list-secondary { color: var(--color-text-secondary); font-size: 12.5px; white-space: nowrap; }
.mini-list-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.mini-list-spacer { flex: 1; min-width: 8px; }
.mini-list-empty { padding: 16px 12px; text-align: center; font-size: 13px; color: var(--color-text-tertiary); }

.toolbar { display: flex; gap: 8px; margin-bottom: 14px; }
.toolbar input[type=text] { flex: 1; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
th {
  color: var(--color-text-secondary);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border-strong);
}
th:first-child { border-top-left-radius: var(--radius-sm); }
th:last-child { border-top-right-radius: var(--radius-sm); }
tbody tr:hover { background: rgba(30, 30, 30, 0.025); }
tr.edit-row td { white-space: normal; background: var(--color-primary-soft); }
tr.edit-row:hover { background: var(--color-primary-soft); }

.edit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.edit-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--color-text-secondary); }
.edit-actions { margin-top: 14px; display: flex; gap: 8px; }
.pager { display: flex; gap: 10px; align-items: center; margin-top: 14px; font-size: 13px; color: var(--color-text-secondary); }

#import-result { font-size: 13px; margin-top: 12px; white-space: pre-wrap; }
textarea#csv-input { width: 100%; height: 120px; font-family: "SF Mono", Menlo, Consolas, monospace; }
.logo-thumb { width: 38px; height: 38px; border-radius: var(--radius-sm); object-fit: cover; background: var(--color-bg); border: 1px solid var(--color-border); }
.merchant-desc-cell { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 图片字段控件（Admin.attachUploadButton，common.js）：单独一个方框，没有
   另外的"上传图片"按钮，也不显示 URL 文本框——空的点它上传，有图点它预览，
   角上叉号删除。 */
.image-field { display: inline-flex; align-items: center; }
.image-picker {
  position: relative;
  width: 64px;
  height: 64px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--color-border-strong);
  background: var(--color-bg);
  overflow: visible;
  cursor: pointer;
}
.image-picker:hover { border-color: var(--color-primary); }
.image-picker.has-image { border-style: solid; border-color: var(--color-border); }
.image-picker.is-uploading { opacity: .5; pointer-events: none; }
.image-picker img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; display: block; }
.image-picker.is-empty img, .image-picker.is-broken img { display: none; }
.image-picker.is-empty::after { content: '+'; color: var(--color-text-tertiary); font-size: 24px; line-height: 1; }
.image-picker.is-broken::after { content: '×'; color: var(--color-danger); font-size: 20px; line-height: 1; }
.image-picker-remove {
  display: none;
  position: absolute;
  top: -7px;
  right: -7px;
  width: 18px;
  height: 18px;
  padding: 0;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--color-surface);
  border-radius: 50%;
  background: var(--color-text-secondary);
  color: #fff;
  font-size: 12px;
  line-height: 1;
}
.image-picker-remove:hover { background: var(--color-danger); }
.image-picker.has-image .image-picker-remove { display: flex; }

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: rgba(15, 23, 42, 0.75);
  cursor: zoom-out;
}
.image-lightbox.is-open { display: flex; }
.image-lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--radius-md); box-shadow: var(--shadow-lg); }

/* Generic status badges — opt-in for any section file that wants a colored
   pill instead of ad-hoc inline styles. Not retrofitted into existing
   sections; available for new ones. */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.badge-neutral { background: var(--color-bg); color: var(--color-text-secondary); }
.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-danger { background: var(--color-danger-soft); color: var(--color-danger); }
.badge-primary { background: var(--color-primary-soft); color: var(--color-primary-dark); }

/* views: hidden unless active */

.view[hidden] { display: none; }
/* 按角色隐藏的菜单项（common.js 的 applyRole）。.nav-item 自己设了 display，
   会盖过 [hidden] 的默认样式，所以要显式写一条。 */
.nav-item[hidden] { display: none; }

/* ============================================================
   Small screens: keep it usable, not full responsive polish —
   this is an internal ops tool used on a laptop/desktop.
   ============================================================ */
@media (max-width: 900px) {
  :root { --sidebar-width: 76px; }
  .sidebar-title, .sidebar-subtitle, .nav-group-label, .nav-item span, .sidebar-footer button span { display: none; }
  .sidebar-brand { justify-content: center; padding: 6px 0 18px; }
  .nav-item { justify-content: center; padding: 10px; }
  .sidebar-footer button { padding: 9px; }
  .content { padding: 20px 16px 60px; }
  .topbar { padding: 0 16px; }
}

/* ============================================================
   Modal（common.js 的 Admin.openModal）
   ============================================================ */

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px;
  overflow-y: auto;
}

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

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px 0;
}

.modal-title { font-size: 17px; font-weight: 700; color: var(--color-text); }
.modal-subtitle { font-size: 13px; color: var(--color-text-secondary); margin-top: 4px; }

.modal-close {
  background: transparent;
  color: var(--color-text-tertiary);
  font-size: 22px;
  line-height: 1;
  padding: 2px 6px;
}
.modal-close:hover { background: var(--color-bg); color: var(--color-text); }

.modal-tabs { padding: 0 22px; margin: 14px 0 0; }

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

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--color-border);
}

/* 对话框里的分组：小标题 + 内容 */
.form-section { margin-bottom: 20px; }
.form-section:last-child { margin-bottom: 0; }
.form-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

/* 勾选项：一行一个开关式的 checkbox + 说明 */
.check-list { display: flex; flex-direction: column; gap: 8px; }
.check-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  color: var(--color-text);
  cursor: pointer;
}
.check-item input { width: auto; margin-top: 3px; }
.check-item .hint { display: block; font-size: 12px; color: var(--color-text-tertiary); margin-top: 2px; }

/* 只读的信息行：标签 + 值 */
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px 16px; }
.info-grid .k { font-size: 12px; color: var(--color-text-tertiary); }
.info-grid .v { font-size: 14px; color: var(--color-text); margin-top: 2px; word-break: break-all; }

/* 用户列表：头像字母 + 昵称/手机号 */
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-name { font-weight: 600; color: var(--color-text); }
.user-sub { font-size: 12px; color: var(--color-text-secondary); margin-top: 2px; }
.badge-row { display: flex; flex-wrap: wrap; gap: 4px; }

/* ============================================================
   问卷编辑器（form-editor.js）——全屏三栏，参考问卷星：
   左：题型 + 大纲；中：问卷本身（所见即所得）；右：选中项的设置。
   用的全是上面的 DevFest 色板：题型用四个品牌色区分，选中态是品牌蓝，
   标题卡顶部是 KV 的四色条。
   ============================================================ */
.fe {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
}

/* 顶栏 */
.fe-top {
  height: 60px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}
.fe-top-left { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
.fe-top-brand { display: flex; align-items: center; gap: 10px; }
.fe-top-brand .brand-wordmark { font-size: 17px; }
.fe-top-brand .brand-wordmark .brace { font-size: 20px; }
.fe-top-divider { width: 1px; height: 18px; background: var(--color-border-strong); }
.fe-top-name { font-size: 14px; font-weight: 700; }
.fe-top-title {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.fe-top-title-text {
  font-size: 15px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 420px;
}
.fe-top-right { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.fe-save-state { font-size: 12.5px; color: var(--color-text-tertiary); display: inline-flex; align-items: center; gap: 6px; }
.fe-save-state.dirty { color: var(--color-warning); }
.fe-save-state.dirty::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand-yellow);
}
.fe-save { padding: 9px 28px; }

/* 三栏 */
.fe-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr) 320px;
}
.fe-left, .fe-right {
  background: var(--color-surface);
  overflow-y: auto;
  padding: 20px 16px 32px;
}
.fe-left { border-right: 1px solid var(--color-border); }
.fe-right { border-left: 1px solid var(--color-border); padding: 20px 20px 32px; }
.fe-panel-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--color-text-tertiary);
  margin: 0 4px 12px;
}

/* 左：题型 */
.fe-types { display: flex; flex-direction: column; gap: 6px; }
.fe-type {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  text-align: left;
  font-weight: 400;
}
.fe-type:hover { background: var(--color-bg); border-color: var(--color-border-strong); }
.fe-type-icon {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--c);
}
.fe-type-icon svg { width: 18px; height: 18px; }
.fe-type-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.fe-type-text b { font-size: 13.5px; }
.fe-type-text small { font-size: 11.5px; color: var(--color-text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fe-type-plus { font-size: 18px; color: var(--color-text-tertiary); }
.fe-type:hover .fe-type-plus { color: var(--color-primary); }

/* 左：大纲 */
.fe-outline { display: flex; flex-direction: column; gap: 2px; }
.fe-outline-empty { font-size: 12.5px; color: var(--color-text-tertiary); padding: 4px; }
.fe-outline-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  border: none;
}
.fe-outline-item:hover { background: var(--color-bg); }
.fe-outline-item.active { background: var(--color-primary-soft); color: var(--color-primary-dark); font-weight: 600; }
.fe-outline-no {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--c);
}
.fe-outline-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 中：画布 */
.fe-canvas { overflow-y: auto; padding: 28px 28px 80px; }
.fe-paper { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }

.fe-head, .fe-q {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.fe-head:hover, .fe-q:hover { border-color: var(--color-border-strong); }
.fe-head.selected, .fe-q.selected { border-color: var(--color-primary); box-shadow: 0 0 0 4px var(--color-primary-soft); }

/* 标题卡 */
.fe-head { overflow: hidden; padding: 0 32px 22px; }
.fe-head-stripe { display: flex; margin: 0 -32px 26px; padding: 0; }
.fe-head-stripe i { display: block; height: 8px; }
.fe-head-stripe i:nth-child(1) { flex: 5; background: var(--brand-blue); }
.fe-head-stripe i:nth-child(2) { flex: 2; background: var(--brand-red); }
.fe-head-stripe i:nth-child(3) { flex: 3; background: var(--brand-yellow); }
.fe-head-stripe i:nth-child(4) { flex: 1.5; background: var(--brand-green); }
.fe-head-title, .fe-head-desc, .fe-q-label-input {
  width: 100%;
  border: none;
  border-bottom: 1.5px solid transparent;
  border-radius: 0;
  padding: 4px 0 6px;
  background: transparent;
  box-shadow: none !important;
  resize: none;
  overflow: hidden;
}
.fe-head-title:hover, .fe-head-desc:hover, .fe-q-label-input:hover { border-bottom-color: var(--color-border); }
.fe-head-title:focus, .fe-head-desc:focus, .fe-q-label-input:focus { border-bottom-color: var(--color-primary); }
.fe-head-title { font-size: 26px; font-weight: 800; letter-spacing: -0.01em; text-align: center; }
.fe-head-desc { font-size: 14px; line-height: 1.7; color: var(--color-text-secondary); text-align: center; margin-top: 6px; }
.fe-head-meta { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.fe-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: var(--color-bg);
  color: var(--color-text-secondary);
  font-size: 12.5px;
  font-weight: 600;
}
.fe-chip svg { width: 14px; height: 14px; }
.fe-chip.warn { background: var(--color-warning-soft); color: var(--color-warning); }

/* 题目卡 */
.fe-q { position: relative; padding: 14px 24px 22px 24px; }
.fe-q::before {
  content: '';
  position: absolute;
  left: -1.5px;
  top: 22px;
  bottom: 22px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--c);
  opacity: 0;
  transition: opacity 0.12s ease;
}
.fe-q.selected::before { opacity: 1; }
.fe-q.dragging { opacity: 0.4; }
.fe-q.drop-before { box-shadow: 0 -4px 0 0 var(--color-primary); }
.fe-q.drop-after { box-shadow: 0 4px 0 0 var(--color-primary); }
.fe-q-bar { display: flex; align-items: center; gap: 8px; min-height: 30px; margin-bottom: 8px; }
.fe-q-grip {
  position: absolute;
  left: 4px;
  top: 20px;
  width: 18px;
  height: 18px;
  color: var(--color-text-tertiary);
  cursor: grab;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.fe-q-grip svg { width: 18px; height: 18px; }
.fe-q:hover .fe-q-grip, .fe-q.selected .fe-q-grip { opacity: 1; }
.fe-q-no {
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  background: var(--c);
}
.fe-q-type {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px 3px 8px;
  border-radius: var(--radius-pill);
  background: var(--color-bg);
  color: var(--color-text-secondary);
  font-size: 12px;
  font-weight: 600;
}
.fe-q-type svg { width: 13px; height: 13px; }
.fe-q-req {
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--color-danger-soft);
  color: var(--color-danger);
  font-size: 11.5px;
  font-weight: 700;
}
.fe-q-spacer { flex: 1; }
.fe-q-tools { display: flex; gap: 2px; opacity: 0; transition: opacity 0.12s ease; }
.fe-q:hover .fe-q-tools, .fe-q.selected .fe-q-tools { opacity: 1; }
.fe-icon-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--color-text-secondary);
  border: none;
}
.fe-icon-btn svg { width: 17px; height: 17px; }
.fe-icon-btn:hover { background: var(--color-bg); color: var(--color-text); }
.fe-icon-btn.danger { background: transparent; }  /* 压过全局 button.danger 的红底 */
.fe-icon-btn.danger:hover { background: var(--color-danger-soft); color: var(--color-danger); }
.fe-icon-btn:disabled { opacity: 0.3; background: transparent; }
.fe-icon-btn.small { width: 26px; height: 26px; }
.fe-icon-btn.small svg { width: 14px; height: 14px; }

.fe-q-label { font-size: 16px; font-weight: 700; line-height: 1.5; margin-bottom: 14px; }
.fe-q-label.empty { color: var(--color-text-tertiary); font-weight: 500; }
.fe-q-label-input { font-size: 16px; font-weight: 700; line-height: 1.5; margin-bottom: 12px; font-family: inherit; }
.fe-q-note { margin-top: 10px; font-size: 12.5px; color: var(--color-text-tertiary); }

/* 选项 */
.fe-opts { display: flex; flex-direction: column; gap: 8px; }
.fe-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  background: var(--color-bg);
  font-size: 14px;
}
.fe-opts.editing .fe-opt { background: transparent; border: 1.5px solid var(--color-border); padding: 0 8px 0 14px; }
.fe-opts.editing .fe-opt:focus-within { border-color: var(--color-primary); }
.fe-mark {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  border: 1.5px solid var(--color-border-strong);
  background: var(--color-surface);
}
.fe-mark.round { border-radius: 50%; }
.fe-mark.square { border-radius: 5px; }
.fe-opt-input { flex: 1; border: none; padding: 9px 0; background: transparent; box-shadow: none !important; }
.fe-opt-fixed { font-weight: 600; }
.fe-other-line { flex: 1; height: 1px; border-bottom: 1.5px dashed var(--color-border-strong); margin-top: 8px; }
.fe-opt-links { display: flex; gap: 18px; margin-top: 4px; padding-left: 4px; }
.fe-link {
  padding: 4px 0;
  background: none;
  border: none;
  color: var(--color-primary-dark);
  font-size: 13px;
  font-weight: 600;
  border-radius: 0;
}
.fe-link:hover { background: none; text-decoration: underline; }
.fe-bulk { width: 100%; font-family: inherit; line-height: 1.7; resize: vertical; }

/* 打分 / 输入框预览 */
.fe-rating { display: flex; gap: 8px; }
.fe-rating span {
  flex: 1;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text-secondary);
}
.fe-rating.ten { gap: 6px; }
.fe-rating.ten span { height: 36px; font-size: 13px; }
.fe-rating span:last-child { background: var(--color-warning-soft); color: var(--color-warning); }
.fe-rating-labels { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12.5px; color: var(--color-text-tertiary); }
.fe-fake-input {
  height: 42px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1.5px dashed var(--color-border-strong);
  display: flex;
  align-items: center;
  font-size: 13.5px;
  color: var(--color-text-tertiary);
}
.fe-fake-input.tall { height: 96px; align-items: flex-start; padding-top: 12px; }

/* 空状态 + 底部添加 */
.fe-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 44px 20px;
  border-radius: var(--radius-lg);
  border: 1.5px dashed var(--color-border-strong);
  color: var(--color-text-tertiary);
  font-size: 13px;
}
.fe-empty b { font-size: 15px; color: var(--color-text-secondary); }
.fe-add {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  border: 1.5px dashed var(--color-border-strong);
}
.fe-add-label { font-size: 13px; font-weight: 700; color: var(--color-text-secondary); margin-right: 4px; }
.fe-add-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border-strong);
  font-size: 13px;
  font-weight: 600;
}
.fe-add-chip svg { width: 15px; height: 15px; color: var(--c); }
.fe-add-chip:hover { background: var(--color-bg); border-color: var(--color-text); }

/* 右：设置 */
.fe-set { margin-bottom: 20px; }
.fe-set-label { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.fe-set-hint { font-size: 12px; color: var(--color-text-tertiary); line-height: 1.6; margin-top: 6px; }
.fe-set input[type=text], .fe-set input[type=datetime-local] { width: 100%; }
.fe-deadline { display: flex; gap: 8px; }
.fe-deadline input { flex: 1; min-width: 0; }
.fe-type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.fe-type-grid button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 4px 8px;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  border: 1.5px solid var(--color-border);
  font-size: 12px;
  font-weight: 600;
}
.fe-type-grid button svg { width: 18px; height: 18px; color: var(--c); }
.fe-type-grid button:hover { background: var(--color-bg); }
.fe-type-grid button.active { border-color: var(--color-primary); background: var(--color-primary-soft); color: var(--color-primary-dark); }
.fe-seg { display: inline-flex; padding: 3px; border-radius: var(--radius-pill); background: var(--color-bg); }
.fe-seg button {
  padding: 6px 16px;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 13px;
  border: none;
}
.fe-seg button:hover { background: transparent; color: var(--color-text); }
.fe-seg button.active { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-md); }
.fe-switch { position: relative; display: inline-block; width: 42px; height: 24px; cursor: pointer; }
.fe-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.fe-switch span {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-pill);
  background: var(--color-border-strong);
  transition: background 0.15s ease;
}
.fe-switch span::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(30, 30, 30, 0.2);
  transition: transform 0.15s ease;
}
.fe-switch input:checked + span { background: var(--color-primary); }
.fe-switch input:checked + span::after { transform: translateX(18px); }
.fe-tip {
  margin-top: 8px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--color-primary-soft);
  color: var(--color-text-secondary);
  font-size: 12.5px;
  line-height: 1.7;
}
.fe-tip b { color: var(--color-text); }
.fe-del-q { margin-top: 8px; width: 100%; }

/* 保存提示 */
.fe-flash {
  position: fixed;
  left: 50%;
  top: 76px;
  transform: translate(-50%, -10px);
  padding: 9px 20px;
  border-radius: var(--radius-pill);
  background: var(--color-danger);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 1001;
}
.fe-flash.ok { background: var(--color-success); }
.fe-flash.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1180px) {
  .fe-body { grid-template-columns: 210px minmax(0, 1fr) 280px; }
  .fe-type-text small { display: none; }
  .fe-top-brand { display: none; }
}

/* ---- 规则说明编辑器（礼包规则 / 打卡规则，public/admin/rules-editor.js） ---- */
.gr-section {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
  background: var(--color-surface, #fff);
}
.gr-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.gr-index { font-weight: 700; color: var(--color-text-secondary); width: 22px; flex: none; }
.gr-title { flex: 1; font-weight: 600; }
.gr-content { width: 100%; min-height: 96px; line-height: 1.7; resize: vertical; }

/* 用户管理：勾选后出现的批量操作条 */
.bulk-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--color-primary-soft, #e8f0fe);
  font-size: 13px;
}
.bulk-bar[hidden] { display: none; }

.management-password-modal .modal-header { padding: 26px 28px 0; }
.management-password-modal .brand-stripe { margin-bottom: 16px; }
.management-password-modal .modal-title { font-size: 22px; }
.management-password-modal .modal-subtitle { margin-top: 8px; line-height: 1.55; }
.management-password-modal .modal-body { padding: 22px 28px 28px; }

.management-password-form {
  display: grid;
  gap: 16px;
}

.management-password-form label {
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.management-password-form input {
  width: 100%;
  min-width: 0;
  padding: 10px 14px;
  font-weight: 400;
}

.management-password-error {
  margin: 0;
  color: var(--color-danger);
  font-size: 13px;
}

.management-password-error:empty { display: none; }

.management-password-actions {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.management-password-actions button { min-height: 42px; }

@media (max-width: 420px) {
  .management-password-modal .modal-header { padding: 22px 20px 0; }
  .management-password-modal .modal-body { padding: 20px; }
}
