/* ============================================================================
   槟榔扫码兑奖系统 - 后台管理样式
   纯原生 CSS, 无任何外部字体 / 图片 / 框架依赖
   配色: 暖橙金 #E8A33D + 深棕 #8B4513 + 背景浅灰 #F5F6F8
   ============================================================================ */

/* ---------------------------------------------------------------
   1. 设计变量 (主题色 / 间距 / 圆角 / 阴影)
   --------------------------------------------------------------- */
:root {
  --primary: #E8A33D;
  --primary-dark: #D08F2A;
  --primary-light: #FDF3E3;
  --brown: #8B4513;
  --brown-dark: #6E350E;
  --brown-light: #A85B22;

  --bg: #F5F6F8;
  --card: #FFFFFF;
  --border: #E6E8EC;
  --border-strong: #D6D9DF;

  --text: #24262B;
  --text-sub: #6B7280;
  --text-muted: #9AA1AC;

  --green: #17A34A;
  --green-bg: #E7F7ED;
  --orange: #E8801A;
  --orange-bg: #FDF0E1;
  --blue: #2563EB;
  --blue-bg: #E8EFFE;
  --gray: #6B7280;
  --gray-bg: #EEF0F3;
  --red: #DC2626;
  --red-bg: #FDECEC;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 4px 14px rgba(16, 24, 40, .08);
  --shadow-lg: 0 18px 50px rgba(16, 24, 40, .18);

  --topbar-h: 58px;
  --sidebar-w: 212px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC",
          "Noto Sans CJK SC", sans-serif;
  --font-mono: "SFMono-Regular", Menlo, Consolas, "Courier New", monospace;
}

/* ---------------------------------------------------------------
   2. 基础重置
   --------------------------------------------------------------- */
* { box-sizing: border-box; }

html, body { height: 100%; }

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

h1, h2, h3, h4, p, figure { margin: 0; }

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

table { border-collapse: collapse; width: 100%; }

[hidden] { display: none !important; }

.muted { color: var(--text-muted); }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--font-mono); }
.text-right { text-align: right; }
.text-center { text-align: center; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: #CFD3DA;
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: #B4B9C2; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------------
   3. 通用控件: 按钮 / 输入 / 标签
   --------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.2;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  white-space: nowrap;
  user-select: none;
}
.btn:hover { background: #FAFAFB; border-color: #C3C8D0; }
.btn:active { transform: translateY(1px); }
.btn:disabled,
.btn.is-loading { opacity: .6; cursor: not-allowed; transform: none; }

.btn-primary {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 1px 2px rgba(232, 163, 61, .4);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

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

.btn-danger { color: var(--red); border-color: #F0BDBD; background: #fff; }
.btn-danger:hover { background: var(--red-bg); border-color: var(--red); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-sub); }
.btn-ghost:hover { background: rgba(0, 0, 0, .05); border-color: transparent; color: var(--text); }

.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-xs { padding: 3px 8px; font-size: 12px; border-radius: 4px; }
.btn-block { width: 100%; padding: 11px 16px; font-size: 15px; }

/* 表格行内的操作按钮组 */
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.input, .select, .textarea {
  width: 100%;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(232, 163, 61, .18);
}
.input:disabled, .select:disabled, .textarea:disabled {
  background: #F3F4F6;
  color: var(--text-muted);
  cursor: not-allowed;
}
/* 校验不通过(如活动配置里的 JSON 格式错误) */
.input.is-invalid, .textarea.is-invalid {
  border-color: var(--red);
  background: #FFFBFB;
}
.input.is-invalid:focus, .textarea.is-invalid:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, .15);
}
.textarea { min-height: 88px; resize: vertical; line-height: 1.6; }
.textarea.mono { font-family: var(--font-mono); font-size: 13px; }
.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-sub) 50%),
                    linear-gradient(135deg, var(--text-sub) 50%, transparent 50%);
  background-position: calc(100% - 15px) 16px, calc(100% - 10px) 16px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

/* 表单字段 */
.field { display: block; margin-bottom: 14px; }
.field-label {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
}
.field-label .req { color: var(--red); margin-left: 2px; }
.field-hint { margin-top: 4px; font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.field-hint.is-error { color: var(--red); }

/* 开关 (纯 CSS checkbox 样式) */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  position: relative;
  width: 42px; height: 23px;
  background: #CBD0D8;
  border-radius: 999px;
  transition: background .2s;
  flex: none;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 19px; height: 19px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .2s;
}
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(19px); }
.switch input:disabled + .switch-track { opacity: .5; }
.switch-text { font-size: 13px; color: var(--text-sub); }

/* 彩标标签 */
.tag {
  display: inline-block;
  padding: 1px 8px;
  font-size: 12px;
  line-height: 19px;
  border-radius: 999px;
  background: var(--gray-bg);
  color: var(--gray);
  white-space: nowrap;
}
.tag-green  { background: var(--green-bg);  color: var(--green); }
.tag-orange { background: var(--orange-bg); color: var(--orange); }
.tag-blue   { background: var(--blue-bg);   color: var(--blue); }
.tag-gray   { background: var(--gray-bg);   color: var(--gray); }
.tag-red    { background: var(--red-bg);    color: var(--red); }
.tag-brown  { background: var(--primary-light); color: var(--brown); }

/* 复选框列 */
.check-col { width: 40px; text-align: center; }
.check-col input { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }

/* ---------------------------------------------------------------
   4. 登录页
   --------------------------------------------------------------- */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1000px 520px at 12% -8%, #FBEED6 0%, rgba(251, 238, 214, 0) 62%),
    radial-gradient(900px 480px at 100% 108%, #F3E1DA 0%, rgba(243, 225, 218, 0) 60%),
    linear-gradient(160deg, #FBF7F1 0%, var(--bg) 55%, #F1F2F5 100%);
}

.login-card {
  width: 100%;
  max-width: 396px;
  padding: 34px 32px 26px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.login-brand { text-align: center; margin-bottom: 24px; }

.login-logo {
  width: 56px; height: 56px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--brown) 100%);
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(139, 69, 19, .3);
}

.login-title { font-size: 20px; font-weight: 700; color: var(--brown); letter-spacing: .5px; }
.login-sub { margin-top: 6px; font-size: 13px; color: var(--text-muted); }

.login-form { margin-top: 4px; }

.login-error {
  margin: 0 0 12px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--red);
  background: var(--red-bg);
  border: 1px solid #F5C9C9;
  border-radius: var(--radius-sm);
}

.login-hint {
  margin-top: 18px;
  padding-top: 14px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  border-top: 1px dashed var(--border);
}
.login-hint b { color: var(--text-sub); }

/* ---------------------------------------------------------------
   5. 应用框架: 顶部栏 / 侧边菜单 / 内容区
   --------------------------------------------------------------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 60;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  background: linear-gradient(90deg, var(--brown-dark) 0%, var(--brown) 55%, var(--brown-light) 100%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .16);
  color: #fff;
}

.topbar-toggle { display: none; }

.icon-btn {
  width: 34px; height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s;
}
.icon-btn:hover { background: rgba(255, 255, 255, .24); }

/* 汉堡图标(纯 CSS) */
.hamburger, .hamburger::before, .hamburger::after {
  display: block;
  width: 16px; height: 2px;
  background: #fff;
  border-radius: 2px;
}
.hamburger { position: relative; }
.hamburger::before, .hamburger::after { content: ""; position: absolute; left: 0; }
.hamburger::before { top: -5px; }
.hamburger::after { top: 5px; }

.topbar-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.topbar-logo {
  width: 30px; height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--brown-dark);
  background: linear-gradient(135deg, #FFE0AE, var(--primary));
  border-radius: 9px;
  flex: none;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 12px 4px 4px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 999px;
}

.user-avatar {
  width: 28px; height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--brown-dark);
  background: #FFE0AE;
  border-radius: 50%;
  flex: none;
  text-transform: uppercase;
}

.user-meta { display: flex; align-items: center; gap: 8px; line-height: 1.2; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; }
.user-role { background: rgba(255, 255, 255, .22); color: #fff; font-size: 11px; line-height: 17px; }

.topbar .btn-ghost { color: rgba(255, 255, 255, .9); }
.topbar .btn-ghost:hover { background: rgba(255, 255, 255, .16); color: #fff; }

.layout { display: flex; flex: 1; padding-top: var(--topbar-h); min-height: 0; }

/* 左侧菜单 */
.sidebar {
  position: fixed;
  top: var(--topbar-h);
  bottom: 0;
  left: 0;
  z-index: 50;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid var(--border);
  transition: transform .22s ease;
}

.menu { flex: 1; padding: 12px 10px; overflow-y: auto; }

.menu-group-title {
  padding: 12px 10px 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  margin-bottom: 3px;
  font-size: 14px;
  color: var(--text-sub);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s, color .15s;
  user-select: none;
}
.menu-item:hover { background: var(--primary-light); color: var(--brown); text-decoration: none; }
.menu-item.active {
  background: linear-gradient(90deg, var(--primary-light), #FFF9F0);
  color: var(--brown);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--primary);
}

.menu-icon {
  width: 20px; height: 20px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: currentColor;
}

.sidebar-foot {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  line-height: 1.7;
  color: var(--text-muted);
}

.sidebar-mask { display: none; }

/* 右侧内容区 */
.content {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  padding: 20px 22px 40px;
}

/* ---------------------------------------------------------------
   6. 页面标题 / 卡片 / 工具条
   --------------------------------------------------------------- */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.page-title { font-size: 19px; font-weight: 700; color: var(--brown); }
.page-desc { margin-top: 2px; font-size: 13px; color: var(--text-muted); }
.page-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: #FCFCFD;
}
.card-title { font-size: 15px; font-weight: 600; color: var(--text); }
.card-title .count { margin-left: 6px; font-size: 12px; font-weight: 400; color: var(--text-muted); }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }

/* 统计卡片网格 */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  position: relative;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--primary);
}
.stat-card.is-brown::before  { background: var(--brown); }
.stat-card.is-green::before  { background: var(--green); }
.stat-card.is-orange::before { background: var(--orange); }
.stat-card.is-blue::before   { background: var(--blue); }
.stat-card.is-gray::before   { background: var(--gray); }

.stat-label { font-size: 12px; color: var(--text-muted); }
.stat-value {
  margin-top: 4px;
  font-size: 25px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stat-value.is-brown { color: var(--brown); }
.stat-value.is-green { color: var(--green); }
.stat-value.is-orange { color: var(--orange); }
.stat-value.is-blue { color: var(--blue); }
.stat-sub { margin-top: 2px; font-size: 12px; color: var(--text-muted); }

/* ---------------------------------------------------------------
   7. 表格
   --------------------------------------------------------------- */
.table-wrap { width: 100%; overflow-x: auto; }

/*
 * 表格宽度策略:
 *  - 内容比容器窄时(min-width:100%)铺满容器
 *  - 内容比容器宽时(width:max-content)保持单行不挤压, 由 .table-wrap 横向滚动
 * 这样列数多的表(如兑换记录)不会把文字挤成竖排
 */
.table {
  min-width: 100%;
  width: max-content;
  max-width: none;
  font-size: 13px;
}

.table thead th,
.table tbody td { white-space: nowrap; }

.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
  text-align: left;
  white-space: nowrap;
  background: #F7F8FA;
  border-bottom: 1px solid var(--border);
}
.table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid #F0F1F4;
  vertical-align: middle;
}
/* 斑马纹 + hover */
.table tbody tr:nth-child(even) { background: #FBFBFC; }
.table tbody tr:hover { background: var(--primary-light); }
.table tbody tr.is-selected { background: #FDF3E3; }
.table tbody tr:last-child td { border-bottom: none; }

.table .cell-code { font-family: var(--font-mono); font-weight: 600; letter-spacing: .4px; }
.table .cell-strong { font-weight: 600; }
.table .cell-ellipsis {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-empty { padding: 46px 16px; text-align: center; color: var(--text-muted); }
.table-empty-icon { font-size: 30px; opacity: .35; margin-bottom: 8px; }

/* 表格工具条(筛选表单) */
.toolbar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: #FCFCFD;
}
.toolbar .field { margin-bottom: 0; }
.toolbar .field-label { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.toolbar .tb-item { width: 150px; }
.toolbar .tb-item.wide { width: 190px; }
.toolbar .tb-item.narrow { width: 110px; }
.toolbar .tb-actions { display: flex; gap: 8px; margin-left: auto; }

/* ---------------------------------------------------------------
   8. 分页
   --------------------------------------------------------------- */
.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: #FCFCFD;
  font-size: 13px;
}
.pager-info { color: var(--text-sub); }
.pager-info b { color: var(--brown); font-variant-numeric: tabular-nums; }
.pager-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.pager-jump { display: flex; align-items: center; gap: 5px; color: var(--text-sub); }
.pager-jump .input {
  width: 58px;
  padding: 5px 6px;
  text-align: center;
  font-size: 13px;
}

/* 批量操作条 */
.batch-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 9px 16px;
  font-size: 13px;
  color: var(--brown);
  background: var(--primary-light);
  border-bottom: 1px solid #F3E2C6;
}
.batch-bar .batch-count { font-weight: 600; }

/* ---------------------------------------------------------------
   9. 概览: 手绘柱状图 + 条形图
   --------------------------------------------------------------- */
.chart {
  padding: 4px 2px 0;
  overflow-x: auto;
}
.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  min-width: 520px;
  height: 190px;
  padding: 0 2px;
  border-bottom: 1px solid var(--border-strong);
}
.chart-col {
  flex: 1 1 0;
  min-width: 16px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
}
.chart-col:hover .chart-bar { filter: brightness(1.08); }
.chart-bar {
  width: 100%;
  max-width: 34px;
  min-height: 3px;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: 4px 4px 0 0;
  transition: height .35s ease;
}
.chart-bar.is-zero { background: var(--border-strong); }
.chart-value {
  font-size: 11px;
  color: var(--text-sub);
  font-variant-numeric: tabular-nums;
}
.chart-axis {
  display: flex;
  gap: 6px;
  min-width: 520px;
  margin-top: 6px;
  padding: 0 2px;
}
.chart-axis-label {
  flex: 1 1 0;
  min-width: 16px;
  text-align: center;
  font-size: 10px;
  line-height: 1.3;
  color: var(--text-muted);
  word-break: break-all;
}

/* 横向条形(市场分布) */
.bar-list { display: flex; flex-direction: column; gap: 11px; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-name {
  width: 130px;
  flex: none;
  font-size: 13px;
  color: var(--text-sub);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-track {
  flex: 1;
  height: 16px;
  background: #F1F2F5;
  border-radius: 4px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  min-width: 2px;
  background: linear-gradient(90deg, var(--primary), var(--brown-light));
  border-radius: 4px;
  transition: width .35s ease;
}
.bar-num {
  width: 62px;
  flex: none;
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  color: var(--brown);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------
   10. 活动配置
   --------------------------------------------------------------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px 18px;
}
.form-grid .field-full { grid-column: 1 / -1; }
.field-inline { display: flex; align-items: center; gap: 10px; }

.flash-state {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: linear-gradient(90deg, var(--primary-light), #FFFDF9);
  border: 1px solid #F3E2C6;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
}
.flash-state .fs-item { display: flex; align-items: center; gap: 6px; color: var(--text-sub); }
.flash-state .fs-item b { color: var(--brown); }
.flash-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--gray);
  flex: none;
}
.flash-dot.is-open { background: var(--green); box-shadow: 0 0 0 4px rgba(23, 163, 74, .16); }

/* ---------------------------------------------------------------
   11. 模态框
   --------------------------------------------------------------- */
.modal-root { position: relative; z-index: 100; }

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  background: rgba(24, 20, 16, .45);
  animation: fadeIn .16s ease;
}

.modal {
  width: 100%;
  max-width: 540px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: modalIn .18s ease;
  margin: auto 0;
}
.modal.is-wide { max-width: 720px; }
.modal.is-narrow { max-width: 400px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 600; color: var(--brown); }
.modal-close {
  width: 28px; height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  line-height: 1;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.modal-close:hover { background: var(--gray-bg); color: var(--text); }

.modal-body { padding: 18px; max-height: calc(100vh - 220px); overflow-y: auto; }
.modal-body.is-flush { padding: 0; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 13px 18px;
  border-top: 1px solid var(--border);
  background: #FCFCFD;
  border-radius: 0 0 var(--radius) var(--radius);
}

.modal-msg { font-size: 14px; line-height: 1.7; color: var(--text); }
.modal-msg .danger-text { color: var(--red); font-weight: 600; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(-14px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

/* 结果展示块(批量生成 / 导入结果) */
.result-box { margin-top: 14px; }
.result-summary {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.result-pill {
  padding: 6px 12px;
  font-size: 13px;
  background: var(--gray-bg);
  border-radius: var(--radius-sm);
  color: var(--text-sub);
}
.result-pill b { color: var(--brown); font-size: 15px; }
.result-pill.is-green { background: var(--green-bg); color: var(--green); }
.result-pill.is-green b { color: var(--green); }
.result-pill.is-orange { background: var(--orange-bg); color: var(--orange); }
.result-pill.is-orange b { color: var(--orange); }
.result-pill.is-red { background: var(--red-bg); color: var(--red); }
.result-pill.is-red b { color: var(--red); }

/* 结果提示条(如"已自动调整验证码位数配置") */
.result-note {
  margin-bottom: 12px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.6;
  border-radius: var(--radius-sm);
  background: var(--orange-bg);
  color: var(--orange);
  border-left: 3px solid var(--orange);
}

.code-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 190px;
  overflow-y: auto;
  padding: 10px;
  background: #FBFBFC;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.code-chip {
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--brown);
  background: #fff;
  border: 1px solid #F3E2C6;
  border-radius: 4px;
}

.error-list {
  margin: 0;
  padding: 10px 10px 10px 14px;
  max-height: 170px;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.8;
  color: var(--red);
  background: var(--red-bg);
  border: 1px solid #F5C9C9;
  border-radius: var(--radius-sm);
}
.error-list li { margin-left: 10px; }

.section-label {
  margin: 16px 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
}
.section-label:first-child { margin-top: 0; }

/* ---------------------------------------------------------------
   12. Toast 提示
   --------------------------------------------------------------- */
.toast-root {
  position: fixed;
  top: 74px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-width: 200px;
  max-width: 380px;
  padding: 11px 15px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--gray);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  pointer-events: auto;
  animation: toastIn .2s ease;
}
.toast.is-out { animation: toastOut .2s ease forwards; }
.toast-icon { flex: none; font-size: 14px; line-height: 1.4; }
.toast-text { flex: 1; word-break: break-word; }

.toast-success { border-left-color: var(--green); background: var(--green-bg); color: #14612F; }
.toast-error   { border-left-color: var(--red);   background: var(--red-bg);   color: #8F1D1D; }
.toast-warning { border-left-color: var(--orange); background: var(--orange-bg); color: #8A4A08; }
.toast-info    { border-left-color: var(--blue);  background: var(--blue-bg);  color: #1A3E9E; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(26px); }
  to   { opacity: 1; transform: none; }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(26px); }
}

/* ---------------------------------------------------------------
   13. 全局 loading
   --------------------------------------------------------------- */
.loading-mask {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(255, 255, 255, .6);
}
.spinner {
  width: 34px; height: 34px;
  border: 3px solid rgba(232, 163, 61, .25);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.loading-text { font-size: 13px; color: var(--brown); }
@keyframes spin { to { transform: rotate(360deg); } }

/* 区块级 loading (卡片内局部) */
.block-loading {
  padding: 46px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.block-loading .spinner { margin: 0 auto 10px; }

/* ---------------------------------------------------------------
   14. 响应式: 宽度 < 900px 时左侧菜单可收起
   --------------------------------------------------------------- */
@media (max-width: 900px) {
  .topbar-toggle { display: inline-flex; }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    width: 236px;
  }
  .sidebar.is-open { transform: none; }

  .sidebar-mask {
    display: block;
    position: fixed;
    inset: var(--topbar-h) 0 0 0;
    z-index: 45;
    background: rgba(24, 20, 16, .38);
    animation: fadeIn .16s ease;
  }

  .content { margin-left: 0; padding: 16px 14px 34px; }

  .topbar { padding: 0 12px; gap: 9px; }
  .topbar-title { font-size: 14px; }
  .user-meta { display: none; }
  .user-chip { padding: 3px; }

  .chart-bars, .chart-axis { min-width: 440px; }
  .toolbar .tb-item, .toolbar .tb-item.wide, .toolbar .tb-item.narrow { width: calc(50% - 5px); }
  .toolbar .tb-actions { margin-left: 0; width: 100%; }
  .toolbar .tb-actions .btn { flex: 1; }

  .modal-mask { padding: 16px 10px; }
  .modal-body { max-height: calc(100vh - 170px); }
  .pager-actions { margin-left: 0; width: 100%; }
  .stat-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

@media (max-width: 560px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .bar-name { width: 84px; }
  .toast-root { left: 12px; right: 12px; align-items: stretch; }
  .toast { max-width: none; }
}

/* 打印时隐藏操作元素 */
@media print {
  .topbar, .sidebar, .toolbar, .pager, .batch-bar, .row-actions, .toast-root { display: none !important; }
  .content { margin-left: 0; }
}
