:root {
  --bg: #fbfbfd;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #86868b;
  --primary: #0071e3;
  --primary-d: #0077ed;
  --primary-soft: rgba(0, 113, 227, 0.10);
  --success: #34c759;
  --error: #ff3b30;
  --border: #d2d2d7;
  --bg-soft: #f2f2f7;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);

  /* 统一字号阶梯：前台与后台共用，保证视觉一致 */
  --fs-display: 30px;   /* 页面主标题 h1 */
  --fs-title: 21px;     /* 卡片标题 h2 */
  --fs-subtitle: 19px;  /* 弹窗标题 h3 */
  --fs-body: 16px;      /* 正文 / 输入框 / 标签基准 */
  --fs-label: 16px;
  --fs-hint: 13px;      /* 说明文字 */
  --fs-small: 13px;     /* 徽标 / 表头 */
  --fs-table: 14px;     /* 表格内容 */
  --font-base: "Noto Sans SC", "Source Han Sans SC", "Source Han Sans CN",
    "WenQuanYi Micro Hei", "WenQuanYi Zen Hei", "PingFang SC", "Microsoft YaHei",
    system-ui, sans-serif;
}

/* 状态徽标 */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.6;
}
.badge.ok { background: rgba(52, 199, 89, 0.14); color: #1c8a3e; }
.badge.fail { background: rgba(255, 59, 48, 0.12); color: #c42318; }


* { box-sizing: border-box; }

body {
  margin: 0;
  /* 优先使用开源免费字体（SIL OFL 许可，无商业版权风险）；未安装时再回退系统字体 */
  font-family: "Noto Sans SC", "Source Han Sans SC", "Source Han Sans CN",
    "WenQuanYi Micro Hei", "WenQuanYi Zen Hei", "PingFang SC", "Microsoft YaHei",
    system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ============ 整体布局：左侧竖导航 + 右侧内容 ============ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 268px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  /* 侧栏独立固定并自带滚动：无论页面怎么放大、菜单多少，都能上下滑动 */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 20px; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 11px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.brand-name { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }

.nav { display: flex; flex-direction: column; gap: 6px; flex: 1; margin-top: 6px; }
.nav-section {
  font-size: 12px; color: var(--muted); letter-spacing: 0.07em;
  text-transform: uppercase; padding: 0 12px 8px;
}
.nav-item {
  display: block; width: 100%; text-align: left;
  padding: 11px 14px; border: none; background: transparent;
  border-radius: 13px; cursor: pointer;
  font-size: 16px; color: var(--text); font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: #f5f5f7; }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 18px; margin-top: 8px; }
.sidebar-foot .user { font-size: 14px; color: var(--muted); margin-bottom: 12px; padding: 0 12px; }
.foot-links { display: flex; flex-direction: column; gap: 4px; }
.foot-links a {
  color: var(--text); text-decoration: none; font-size: 14px;
  padding: 8px 12px; border-radius: 9px; transition: background 0.15s;
}
.foot-links a:hover { background: #f5f5f7; }

/* ============ 右侧内容区 ============ */
/* 不再给内容区固定高度+内部滚动条：改由整个页面滚动，
   滚动条才会出现在窗口最右侧，而不是停在 max-width 边界（屏幕中间） */
.content { flex: 1; padding: 24px 32px; max-width: 1000px; margin-left: 268px; }

.content-head { margin-bottom: 12px; }
.content-head h1 {
  font-size: var(--fs-display); font-weight: 700; letter-spacing: -0.02em;
  margin: 0 0 10px;
}
.tool-desc { color: var(--muted); font-size: var(--fs-body); margin: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.card h2 { font-size: var(--fs-title); font-weight: 600; margin: 0 0 12px; letter-spacing: -0.01em; }

/* ============ 表单 ============ */
label { display: block; font-weight: 500; font-size: 16px; margin: 10px 0 5px; }
input[type=text], input[type=password], input[type=datetime-local], textarea, select {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 16px; font-family: inherit; background: #fff; color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; line-height: 1.55; }
.longtext { font-family: "Noto Sans Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13.5px; line-height: 1.5; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.checkbox-label { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 500; margin: 10px 0; cursor: pointer; }
.checkbox-label input { width: 18px; height: 18px; accent-color: var(--primary); }
.hint { display: block; color: var(--muted); font-size: 13px; margin-top: 5px; line-height: 1.45; }

.field { margin-bottom: 2px; }

/* 列表字段：逐行输入合集ID */
.list-editor { margin: 4px 0 2px; }
.list-rows {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  margin-bottom: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.list-row { display: flex; gap: 6px; align-items: center; }
.list-input {
  flex: 1 1 auto; min-width: 0;
  max-width: 260px;
  height: 36px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; background: var(--bg); color: var(--text);
  font-family: "Noto Sans Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow: hidden; text-overflow: ellipsis;
}
.list-input:focus { outline: none; border-color: var(--primary); }
.list-input.dup { border-color: var(--error); background: #fff3f3; }
.list-del {
  flex: 0 0 auto;
  width: 28px; height: 28px; padding: 0;
  border: 1px solid var(--border); border-radius: 7px;
  background: var(--bg-soft); color: var(--muted);
  cursor: pointer; font-size: 13px; line-height: 1;
}
.list-del:hover { color: var(--error); border-color: var(--error); }
.list-add { margin-bottom: 4px; }
.list-warn { color: var(--error); font-size: 13px; font-weight: 600; margin-top: 6px; }

/* 高级选项：默认展开 */
.advanced {
  margin: 12px 0 4px; border: 1px solid var(--border);
  border-radius: 14px; padding: 2px 14px 10px; background: #fbfbfd;
}
.advanced > summary {
  cursor: pointer; list-style: none; font-size: 16px; font-weight: 600;
  color: var(--text); padding: 11px 0; user-select: none;
}
.advanced > summary::-webkit-details-marker { display: none; }
.advanced > summary::after {
  content: "⌄"; float: right; color: var(--muted); font-size: 18px; line-height: 1;
  transition: transform 0.2s;
}
.advanced[open] > summary::after { transform: rotate(180deg); }
.adv-body { margin-top: 4px; }

/* ============ 分组字段（彩蛋合集等多组可增删） ============ */
.group-container { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 4px; }
.group-item {
  border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px;
  background: #fff; position: relative;
}
.group-item-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; font-size: 14px; color: var(--muted);
}
.group-item-head .grp-idx { color: var(--primary); font-weight: 600; }
.group-item .grp-field { margin-bottom: 10px; }
.group-item .grp-field label { margin: 6px 0 4px; font-size: 14px; }
.group-add { margin-top: 6px; }
.group-del { padding: 4px 12px; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 14px 28px; border: none; border-radius: var(--radius-sm);
  font-size: 16px; font-weight: 500; cursor: pointer; text-decoration: none;
  font-family: inherit; transition: background 0.15s, transform 0.05s;
}
.btn-primary { background: var(--primary); color: #fff; margin-top: 16px; width: 100%; }
.btn-primary:hover { background: var(--primary-d); }
.btn-primary:active { transform: scale(0.992); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-success { background: var(--success); color: #fff; margin-top: 18px; }
.btn-mini {
  padding: 5px 11px; font-size: 13px; margin-right: 6px;
  border: 1px solid var(--border); background: #fff; border-radius: 8px; cursor: pointer;
  font-family: inherit; color: var(--text);
}
.btn-mini:hover { border-color: var(--primary); color: var(--primary); }
.btn-mini.danger:hover { border-color: var(--error); color: var(--error); }

/* ============ 进度 / 日志 ============ */
.progress-bar { height: 18px; background: #e8e8ed; border-radius: 10px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--primary); border-radius: 10px; transition: width 0.3s; }
.progress-text { margin-top: 12px; color: var(--muted); font-size: 15px; }
.log-box {
  margin-top: 20px; background: #1d1d1f; color: #f5f5f7; padding: 20px;
  border-radius: 14px; height: 320px; overflow-y: auto; font-size: 13.5px;
  line-height: 1.7; white-space: pre-wrap; word-break: break-all;
  font-family: "Noto Sans Mono", ui-monospace, Menlo, Consolas, monospace;
}

/* ============ 提示 ============ */
.alert { padding: 12px 16px; border-radius: 12px; margin: 14px 0; font-size: 15px; }
.alert-error { background: #fff0ef; color: var(--error); border: 1px solid #ffd0cc; }

/* ============ 登录页 ============ */
.login-body {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(1100px 600px at 12% -8%, rgba(0, 113, 227, 0.16), transparent 60%),
    radial-gradient(900px 560px at 105% 110%, rgba(52, 199, 89, 0.14), transparent 55%),
    linear-gradient(160deg, #fbfbfd 0%, #f1f3f8 100%);
}
.login-card {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  padding: 52px 44px 40px; border-radius: 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.10), 0 1px 0 rgba(255, 255, 255, 0.6) inset;
  width: 380px; max-width: 92vw; border: 1px solid rgba(255, 255, 255, 0.7);
}
.login-brand { display: flex; flex-direction: column; align-items: center; text-align: center; }
.login-logo {
  width: 64px; height: 64px; border-radius: 18px;
  background: linear-gradient(150deg, #0a84ff, #0071e3);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 30px; box-shadow: 0 10px 24px rgba(0, 113, 227, 0.35); margin-bottom: 18px;
}
.login-title { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.login-sub { font-size: 12px; letter-spacing: 0.32em; color: var(--muted); margin-top: 6px; }
.login-tagline { text-align: center; color: var(--muted); font-size: 15px; margin: 16px 0 28px; }
.login-field { margin-top: 16px; }
.login-field label { margin: 16px 0 8px; font-size: 14px; color: var(--text); }
.login-field input {
  padding: 15px 16px; font-size: 16px; border-radius: 14px;
  border: 1px solid var(--border); background: rgba(255, 255, 255, 0.9);
}
.login-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.login-btn { width: 100%; margin-top: 28px; padding: 16px; font-size: 17px; font-weight: 600; letter-spacing: 0.1em; border-radius: 14px; }
.login-foot { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 26px; letter-spacing: 0.04em; }

/* ============ 后台管理 ============ */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 52px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
}
.brand-top { font-weight: 600; font-size: var(--fs-title); letter-spacing: -0.01em; }
.topbar-right { display: flex; align-items: center; gap: 18px; }
.user { color: var(--muted); font-size: 14px; }
.link { color: var(--primary); text-decoration: none; font-size: 14px; }
.link:hover { text-decoration: underline; }

/* 后台加宽：原来 980px 装 9 列表格太挤。同时去掉内部滚动，
   改由整页滚动，滚动条回到窗口最右侧（与前台一致）。 */
.container {
  max-width: 1440px; margin: 52px auto 0; padding: 0 24px;
  display: flex; flex-direction: column; gap: 14px;
}

.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-form label { margin-top: 12px; font-size: var(--fs-body); }
.grid-form .btn-primary { grid-column: 1 / -1; margin-top: 18px; }
@media (max-width: 640px) { .grid-form { grid-template-columns: 1fr; } }

/* 原生日期选择器美化：与统一字号/圆角/聚焦态一致，去掉原生偏大的观感 */
input[type=date] {
  width: 100%; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: var(--fs-body); font-family: inherit; background: #fff; color: var(--text);
  height: 50px; transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none; appearance: none;
}
input[type=date]::-webkit-calendar-picker-indicator {
  cursor: pointer; opacity: 0.55; transition: opacity 0.15s;
}
input[type=date]::-webkit-calendar-picker-indicator:hover { opacity: 0.9; }
input[type=date]:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* 表格 */
.user-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.user-table th, .user-table td { padding: 9px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.user-table th { color: var(--muted); font-weight: 500; font-size: 13px; white-space: nowrap; }
/* 操作列按钮不换行，避免窄屏时挤成多行导致行高参差 */
.user-table .ops { white-space: nowrap; }
.user-table tr:hover td { background: #fafafc; }
.ops { white-space: nowrap; }
.ops button { margin-right: 6px; }
.ppreview { display: inline-block; max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); line-height: 1.4; vertical-align: top; }
.muted { color: var(--muted); }
.msg { margin-top: 16px; font-size: 14.5px; }
.msg.ok { color: var(--success); }
.msg.err { color: var(--error); }

/* ============ 权限多选 / 文件管理 ============ */
.full-col { grid-column: 1 / -1; }
.perm-head {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 500; font-size: 16px; margin: 16px 0 10px;
}
.perm-actions { display: flex; gap: 8px; }
.perm-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px 10px;
}
.perm-item {
  display: flex; align-items: center; gap: 9px; margin: 0;
  font-size: 15px; font-weight: 500; cursor: pointer;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 12px;
  background: #fff;
}
.perm-item input { width: 18px; height: 18px; accent-color: var(--primary); }

.files-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.files-head h2 { margin: 0; }
.files-actions { display: flex; align-items: center; gap: 10px; }
.files-actions .muted { font-size: 14px; }
.table-scroll { max-height: 460px; overflow-y: auto; border: 1px solid var(--border); border-radius: 14px; }
.table-scroll .user-table { margin: 0; }
.table-scroll .user-table th { position: sticky; top: 0; background: var(--surface); }
#files-check-all { width: 18px; height: 18px; accent-color: var(--primary); }
.file-check { width: 18px; height: 18px; accent-color: var(--primary); }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.32);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal {
  background: var(--surface); border-radius: 20px; padding: 26px 28px;
  width: 440px; max-width: 100%; box-shadow: var(--shadow); max-height: 88vh; overflow-y: auto;
}
/* 加宽：原来的 760px 装 6~7 列会把「操作/下载」列挤到看不见 */
.modal-wide { width: 1060px; max-width: 96vw; }
.modal h3 { margin: 0 0 16px; font-size: var(--fs-subtitle); font-weight: 600; letter-spacing: -0.01em; }
.modal .grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.modal .grid-form .btn-primary { grid-column: 1 / -1; margin-top: 24px; }
.modal .btn-mini { margin-top: 14px; }
@media (max-width: 640px) { .modal .grid-form { grid-template-columns: 1fr; } }

/* ============ 打包等待遮罩 ============ */
.packaging-overlay {
  position: fixed; inset: 0; background: rgba(20, 22, 28, 0.55);
  display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px;
  backdrop-filter: blur(2px);
}
.packaging-box {
  background: var(--surface); border-radius: 18px; padding: 34px 38px; width: 380px; max-width: 100%;
  box-shadow: var(--shadow); text-align: center;
}
.packaging-box .spinner {
  width: 44px; height: 44px; margin: 0 auto 18px; border-radius: 50%;
  border: 4px solid var(--border); border-top-color: var(--primary);
  animation: spin 0.9s linear infinite;
}
.packaging-box .packaging-text { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.packaging-box .packaging-sub { margin-top: 10px; font-size: 13px; color: var(--muted); line-height: 1.6; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ 右下角问卷悬浮按钮 ============ */
.survey-fab {
  position: fixed; right: 26px; bottom: 26px; z-index: 150;
  width: 56px; height: 56px; border-radius: 50%;
  border: none; cursor: pointer;
  background: var(--primary); color: #fff; font-size: 24px; line-height: 1;
  box-shadow: 0 8px 24px rgba(0, 113, 227, 0.35);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
}
.survey-fab:hover { background: var(--primary-d); transform: scale(1.06); box-shadow: 0 10px 28px rgba(0, 113, 227, 0.45); }
.survey-fab:active { transform: scale(0.96); }

/* ============ 参数详情表 ============ */
.params-meta { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; padding: 4px 10px; margin-bottom: 4px; }
.params-table { width: 100%; border-collapse: collapse; }
.params-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 15px; vertical-align: top; }
.params-table .pk { width: 200px; color: var(--muted); font-weight: 500; word-break: break-all; }
.params-table .pv { color: var(--text); white-space: pre-wrap; word-break: break-all; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; }

/* ============ 响应式：窄屏侧栏转顶部 ============ */
@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: sticky; top: 0; bottom: auto; z-index: 20;
    flex-direction: column; align-items: stretch; flex-wrap: nowrap;
    padding: 12px 14px; gap: 8px;
  }
  .brand { padding: 0; justify-content: center; }
  .nav {
    flex-direction: row; flex-wrap: nowrap; gap: 8px; margin: 0;
    overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch;
  }
  .nav-section { display: none; }
  .nav-item { width: auto; padding: 9px 14px; font-size: 14px; white-space: nowrap; }
  .sidebar-foot {
    border-top: 1px solid var(--border); border-left: none;
    padding: 12px 0 0; margin: 0; display: flex; align-items: center;
    justify-content: center; gap: 16px; flex-wrap: wrap;
  }
  .sidebar-foot .user { margin: 0; padding: 0; }
  .foot-links { flex-direction: row; gap: 12px; flex-wrap: wrap; justify-content: center; }
  .content { padding: 20px 16px; margin-left: 0; }
  .content-head h1 { font-size: 26px; }
  .card { padding: 24px 18px; }
  .log-box { height: 300px; }
}

/* 超小屏（手机竖屏）进一步收窄间距 */
@media (max-width: 480px) {
  .brand-name { font-size: 17px; }
  .content { padding: 18px 12px; }
  .card { padding: 20px 14px; border-radius: 14px; }
  .content-head h1 { font-size: 22px; }
}
