:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e5e8f0;
  --border-strong: #d3d8e5;
  --text: #1a1f2b;
  --text-2: #4a5264;
  --muted: #8b93a6;
  --primary: #2f5cff;
  --primary-dark: #1f47d6;
  --primary-soft: #edf1ff;
  --danger: #e5484d;
  --danger-soft: #fdeced;
  --success: #11a15f;
  --success-soft: #e9f8f0;
  --warning: #d98300;
  --warning-soft: #fff4e0;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(19, 27, 51, 0.04), 0 8px 24px rgba(19, 27, 51, 0.06);
  --shadow-sm: 0 1px 2px rgba(19, 27, 51, 0.06);
  --sidebar-w: 236px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', 'Noto Sans SC', sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}

a {
  color: var(--primary);
  text-decoration: none;
}

button {
  font-family: inherit;
  font-size: inherit;
}

/* ---------- 登录 ---------- */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #e7edff 0%, var(--bg) 55%);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 28px 28px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, #4b74ff, #2f5cff 60%, #1f47d6);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 6px 14px rgba(47, 92, 255, 0.28);
  flex: none;
}

.brand-text strong {
  display: block;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.brand-text span {
  font-size: 12px;
  color: var(--muted);
}

.auth-card h1 {
  font-size: 20px;
  margin-bottom: 4px;
}

.auth-sub {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 22px;
}

.auth-hint {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  line-height: 1.7;
}

.auth-hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text-2);
  background: #fff;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* ---------- 布局 ---------- */
.shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  z-index: 40;
  transition: transform 0.24s ease;
}

.sidebar .brand {
  padding: 0 6px;
  margin-bottom: 20px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
}

.nav-group {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.06em;
  padding: 14px 12px 6px;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  cursor: pointer;
  font-size: 13.5px;
  border: none;
  background: none;
  text-align: left;
  width: 100%;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 600;
}

.nav-item .ico {
  width: 18px;
  height: 18px;
  flex: none;
  opacity: 0.85;
}

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 8px;
}

.who {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.who:hover {
  background: var(--surface-2);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8ea6ff, #2f5cff);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  flex: none;
}

.who-meta {
  min-width: 0;
}

.who-meta strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.who-meta span {
  font-size: 11.5px;
  color: var(--muted);
}

.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 28px;
  background: rgba(244, 246, 251, 0.86);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid transparent;
}

.topbar.scrolled {
  border-bottom-color: var(--border);
}

.topbar h1 {
  font-size: 17px;
}

.topbar .sub {
  font-size: 12.5px;
  color: var(--muted);
}

.topbar-spacer {
  flex: 1;
}

.content {
  padding: 8px 28px 40px;
  max-width: 1280px;
  width: 100%;
}

.hamburger {
  display: none;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-2);
}

.scrim {
  display: none;
}

/* ---------- 通用组件 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-pad {
  padding: 18px 20px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  row-gap: 10px;
}

.card-head h2 {
  font-size: 14.5px;
}

.card-head .sub {
  font-size: 12px;
  color: var(--muted);
}

.card-body {
  padding: 18px 20px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}

.stat {
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.stat::after {
  content: '';
  position: absolute;
  right: -20px;
  top: -28px;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: var(--primary-soft);
  opacity: 0.7;
}

.stat .label {
  font-size: 12.5px;
  color: var(--muted);
}

.stat .value {
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.stat .hint {
  font-size: 11.5px;
  color: var(--muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-2);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(47, 92, 255, 0.3);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-danger {
  color: var(--danger);
  border-color: #f3c9cb;
  background: #fff;
}

.btn-danger:hover {
  background: var(--danger-soft);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-2);
}

.btn-ghost:hover {
  background: var(--surface-2);
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12.5px;
  border-radius: 8px;
}

.btn-block {
  width: 100%;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

/* 两列并排的表单字段（窄屏自动堆叠） */
.form-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
}

.field > label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

.field .req {
  color: var(--danger);
  margin-left: 2px;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  appearance: none;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 92, 255, 0.14);
}

.textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.65;
}

.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' stroke='%238b93a6' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.field-error {
  font-size: 12px;
  color: var(--danger);
}

/* 只读展示值（如渠道用户继承来的渠道名） */
.readonly-value {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-strong);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 14px;
}

.input.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(229, 72, 77, 0.12);
}

.hint {
  font-size: 12px;
  color: var(--muted);
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.row-end {
  justify-content: flex-end;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.badge-primary {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-color: #dbe3ff;
}

.badge-success {
  background: var(--success-soft);
  color: var(--success);
  border-color: #c9eddb;
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #f6d3d5;
}

.badge-warning {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: #f6e2bd;
}

/* ---------- 表格 ---------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

table.data th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  font-size: 12.5px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
}

table.data td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-2);
}

table.data tbody tr:hover {
  background: #fbfcff;
}

table.data tbody tr:last-child td {
  border-bottom: none;
}

.cell-strong {
  color: var(--text);
  font-weight: 500;
}

/* 单元格不换行 + 摘要省略，避免窄屏时列被压成逐字换行 */
table.data .cell-nowrap {
  white-space: nowrap;
}

/* 数据 ID 列：等宽数字，弱化显示 */
table.data .cell-id {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

table.data .time-sub {
  font-size: 11.5px;
  margin-top: 2px;
  color: var(--muted);
}

table.data .cell-summary {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-actions {
  display: flex;
  gap: 2px;
  justify-content: flex-end;
  white-space: nowrap;
}

/* 操作列是表格最贵的一段宽度：按钮内边距收一点 */
.cell-actions .btn-sm {
  padding: 0 7px;
}

.tr-deleted td {
  opacity: 0.62;
}

/* ---------- 空态 ---------- */
.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--muted);
}

.empty strong {
  display: block;
  color: var(--text-2);
  font-size: 14px;
  margin-bottom: 4px;
}

.empty p {
  margin: 0;
  font-size: 12.5px;
}

/* ---------- 图表 ---------- */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 150px;
  padding-top: 8px;
}

.chart .col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  height: 100%;
  min-width: 0;
}

.chart .bar {
  width: 100%;
  border-radius: 6px 6px 3px 3px;
  background: linear-gradient(180deg, #6c8bff, #2f5cff);
  min-height: 3px;
  transition: height 0.35s ease;
}

.chart .bar.zero {
  background: #e9ecf5;
}

.chart .x {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  transform: scale(0.92);
}

.bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bars .item .line {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  margin-bottom: 5px;
  color: var(--text-2);
}

.bars .item .line b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.bars .track {
  height: 7px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.bars .fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7d99ff, #2f5cff);
}

/* ---------- 分栏 ---------- */
.split {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 16px;
  align-items: start;
}

.split-3 {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
  align-items: start;
}

/* ---------- 模态 ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 23, 41, 0.42);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 100;
  animation: fade 0.15s ease;
}

.modal {
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.24);
  animation: pop 0.18s ease;
}

.modal.modal-lg {
  max-width: 760px;
}

.modal.modal-xl {
  max-width: 1120px;
}

.modal-head {
  display: flex;
  align-items: center;
  padding: 18px 20px 10px;
}

.modal-head h3 {
  font-size: 16px;
  flex: 1;
}

.modal-body {
  padding: 6px 20px 4px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px 20px;
}

/* ---------- 记录详情：数据状态 / 数据内容 两张卡片 ---------- */
.detail-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 14px;
  background: var(--surface);
}

.detail-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.detail-card-head::before {
  content: '';
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: var(--primary);
}

.detail-card-body {
  padding: 2px 16px 6px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.detail-item {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  min-width: 0;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}

.detail-item:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.detail-item.wide {
  grid-column: 1 / -1;
}

.detail-item.accent {
  margin: 0 -16px;
  padding: 12px 16px;
  background: var(--primary-soft);
}

.detail-item-label {
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
}

.detail-item-value {
  min-width: 0;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text);
  overflow-wrap: anywhere;
}

.detail-item-value .hint {
  margin-top: 2px;
}

@media (max-width: 620px) {
  .detail-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .detail-item:nth-last-child(2) {
    border-bottom: 1px solid var(--border);
  }
}

/* ---------- 数据使用者：使用浮层 / 批量使用 ---------- */
.use-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.use-toolbar .spacer {
  flex: 1;
}

.fmt-group {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 5px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12.5px;
  color: var(--text-2);
}

.fmt-group label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  cursor: pointer;
}

.copy-btn {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-left: 8px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  vertical-align: middle;
  transition: background 0.15s ease, color 0.15s ease;
}

.copy-btn:hover {
  background: var(--surface-2);
  color: var(--primary);
}

.copy-btn.copied {
  color: var(--success);
}

/* 批量使用表格 */
.use-table-wrap {
  max-height: 52vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

table.use-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

table.use-table th,
table.use-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: top;
}

table.use-table th:last-child,
table.use-table td:last-child {
  border-right: 0;
}

table.use-table tbody tr:last-child td {
  border-bottom: 0;
}

table.use-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  font-weight: 600;
  color: var(--text-2);
  text-align: left;
  user-select: none;
}

table.use-table th.selectable {
  cursor: pointer;
}

table.use-table th.selectable:hover {
  color: var(--primary);
}

table.use-table th.col-sel,
table.use-table td.col-sel {
  background: var(--primary-soft);
}

table.use-table th.col-sel {
  box-shadow: inset 0 -2px 0 var(--primary);
}

table.use-table th .col-check {
  display: inline-block;
  width: 14px;
  margin-right: 6px;
  color: var(--primary);
  font-weight: 700;
  text-align: center;
  vertical-align: -2px;
}

table.use-table td.cell-id {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

table.use-table td.cell-ro {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: text;
  cursor: text;
}

/* 可编辑单元格：像表格编辑器一样直接点击编辑 */
table.use-table td.cell-edit {
  min-width: 140px;
  padding: 0;
  cursor: text;
  outline: none;
}

table.use-table td.cell-edit {
  white-space: pre-wrap;
  word-break: break-word;
}

/* 单元格内容区域：padding 让 contenteditable 内容有呼吸感 */
table.use-table td.cell-edit {
  padding: 8px 10px;
}

/* hover：给可编辑单元格一个淡边框提示可编辑 */
table.use-table td.cell-edit:hover {
  box-shadow: inset 0 0 0 1px var(--border-strong);
  background: var(--surface-2);
}

/* 聚焦（正在编辑）：明显高亮 */
table.use-table td.cell-edit:focus {
  box-shadow: inset 0 0 0 2px var(--primary);
  background: var(--surface);
}

/* 可编辑单元格里的占位提示（空值时） */
table.use-table td.cell-edit:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  pointer-events: none;
}

.use-table-note {
  margin: 8px 0 0;
}

.btn.is-active {
  border-color: var(--primary);
  color: var(--primary);
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
}

/* ---------- Toast ---------- */
.toast-root {
  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: #1d2433;
  color: #fff;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.22);
  animation: toastIn 0.2s ease;
  max-width: 90vw;
}

.toast.error {
  background: var(--danger);
}

.toast.success {
  background: var(--success);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* ---------- Tabs ---------- */
.tabs {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  gap: 2px;
}

.tab {
  border: none;
  background: none;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
}

.tab.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* ---------- 字段编辑器 ---------- */
.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px 10px;
  align-items: stretch;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  margin-bottom: 8px;
}

/* 显式定位：第一行 名称 / 类型，第二行 提示 / 默认值，右侧操作按钮跨两行 */
.field-row > .fr-name {
  grid-column: 1;
  grid-row: 1;
}

.field-row > .fr-type {
  grid-column: 2;
  grid-row: 1;
}

.field-row > .fr-ph {
  grid-column: 1;
  grid-row: 2;
}

.field-row > .fr-def {
  grid-column: 2;
  grid-row: 2;
}

.field-row > .drag {
  grid-column: 3;
  grid-row: 1 / span 2;
  align-self: start;
  display: flex;
  gap: 2px;
}

.field-row > .fr-opts,
.field-row > .flags {
  grid-column: 1 / -1;
}

.fr-cell {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.fr-label {
  display: block;
  margin-bottom: 4px;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.field-row .mini {
  width: 100%;
  min-height: 32px;
  font-size: 13px;
  padding: 4px 8px;
}

/* 宽屏：四个输入框排成一行，更紧凑 */
@media (min-width: 1360px) {
  .field-row {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1.1fr) minmax(0, 1fr) auto;
  }

  .field-row > .fr-name {
    grid-column: 1;
    grid-row: 1;
  }

  .field-row > .fr-type {
    grid-column: 2;
    grid-row: 1;
  }

  .field-row > .fr-ph {
    grid-column: 3;
    grid-row: 1;
  }

  .field-row > .fr-def {
    grid-column: 4;
    grid-row: 1;
  }

  .field-row > .drag {
    grid-column: 5;
    grid-row: 1;
    align-self: end;
  }
}

.flags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding-top: 4px;
  border-top: 1px dashed var(--border);
  margin-top: 2px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.check input {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  accent-color: var(--primary);
  margin: 0;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  cursor: pointer;
  background: var(--surface);
  font-size: 13px;
}

.chip.on {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 500;
}

.chip input {
  accent-color: var(--primary);
  margin: 0;
}

.preview-table {
  font-size: 12.5px;
}

.preview-table td,
.preview-table th {
  padding: 6px 10px;
}

.preview-err {
  color: var(--danger);
}

/* ---------- 记录列表：选择框 / 批量操作 / 内联结算 ---------- */
table.data .col-check {
  width: 34px;
  padding-right: 0;
}

/* 注意：这里是表格里的「裸复选框」（input.check），
   不能写成 .check，否则会把 label.check 也压成 15×15 */
input.check {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  accent-color: var(--primary);
  cursor: pointer;
  vertical-align: middle;
}

.settle-select {
  min-width: 88px;
  height: 28px;
  font-size: 12.5px;
  padding: 0 6px;
}

.batch-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--primary-soft);
  border-top: 1px solid #dbe3ff;
  border-bottom: 1px solid #dbe3ff;
}

.batch-bar-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-dark);
}

/* ---------- 批量提交（后台提交页 + 匿名分享页共用） ---------- */
.batch-intro {
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.batch-intro-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
}

.batch-intro .hint {
  margin: 2px 0 0;
  font-size: 12.5px;
  line-height: 1.7;
}

.batch-alert {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13px;
  line-height: 1.65;
}

.batch-alert.success {
  background: var(--success-soft);
  border-color: #c9eddb;
  color: var(--success);
}

.batch-alert.danger {
  background: var(--danger-soft);
  border-color: #f6d3d5;
  color: var(--danger);
}

.batch-alert strong {
  display: block;
  font-size: 13px;
}

.batch-alert ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.batch-alert-meta {
  display: inline-block;
  margin-top: 4px;
  font-size: 12.5px;
  opacity: 0.85;
}

.share-tabs {
  margin-bottom: 16px;
  display: flex;
  width: 100%;
}

.share-tabs .tab {
  flex: 1;
  text-align: center;
}

/* ---------- 移动端 ---------- */
.mobile-only {
  display: none;
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 0 0 40px rgba(15, 23, 42, 0.18);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    margin-left: 0;
  }

  .hamburger {
    display: inline-flex;
  }

  .topbar {
    padding: 12px 16px;
  }

  .content {
    padding: 4px 14px 32px;
  }

  .split,
  .split-3 {
    grid-template-columns: 1fr;
  }

  .scrim.show {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(17, 23, 41, 0.35);
    z-index: 35;
  }

  .field-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .field-row > .fr-name,
  .field-row > .fr-type,
  .field-row > .fr-ph,
  .field-row > .fr-def,
  .field-row > .fr-opts,
  .field-row > .flags,
  .field-row > .drag {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .field-row > .drag {
    justify-content: flex-end;
  }

  table.data th,
  table.data td {
    padding: 10px 10px;
  }

  .card-head .topbar-spacer {
    display: none;
  }

  table.data .cell-nowrap {
    white-space: nowrap;
  }

  table.data .desktop-only {
    display: none;
  }

  table.data .mobile-only {
    display: block;
    font-size: 11px;
    margin-top: 2px;
    /* 父级 td 常带 cell-nowrap，这里允许摘要换行，避免把表格撑宽 */
    white-space: normal;
  }

  table.data .cell-summary {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  table.data tbody tr {
    cursor: pointer;
  }

  table.data .cell-actions {
    gap: 0;
  }

  table.data td.actions-cell,
  table.data th.actions-head {
    position: sticky;
    right: 0;
    background: var(--surface);
    box-shadow: -10px 0 12px -10px rgba(19, 27, 51, 0.22);
  }

  table.data th.actions-head {
    background: var(--surface-2);
  }

  .modal,
  .modal.modal-lg,
  .modal.modal-xl {
    max-width: 100%;
    border-radius: 16px;
  }

  .stat .value {
    font-size: 22px;
  }
}

@media (max-width: 560px) {
  .form-cols {
    grid-template-columns: 1fr;
  }

  .grid-cards {
    grid-template-columns: 1fr 1fr;
  }

  .card-body {
    padding: 14px;
  }

  .card-head {
    padding: 14px;
  }
}

/* ---------- 语言切换 ---------- */
.lang-switch {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.lang-switch button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  padding: 6px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.lang-switch button:hover {
  color: var(--text);
}

.lang-switch button.on {
  background: var(--surface);
  color: var(--primary-dark);
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.1);
}

.sidebar-foot .lang-switch {
  width: 100%;
  margin-bottom: 8px;
}

.sidebar-foot .lang-switch button {
  flex: 1;
}

.auth-lang {
  margin: 20px auto 0;
}

/* ---------- 匿名分享页 ---------- */
.share-wrap {
  min-height: 100vh;
  padding: 28px 20px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, #e7edff 0%, var(--bg) 55%);
}

.share-top {
  width: 100%;
  max-width: 560px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.share-top .brand {
  margin-bottom: 0;
}

.share-card {
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow);
}

.share-head {
  margin-bottom: 18px;
}

.share-head h1 {
  font-size: 19px;
  letter-spacing: -0.01em;
}

.share-card > .card-pad h1,
.share-card > .card-body > h1 {
  font-size: 19px;
}

.share-icon {
  width: 54px;
  height: 54px;
  margin: 8px auto 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.share-icon.success {
  background: var(--success-soft);
  color: var(--success);
}

.share-icon.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.share-card h1 {
  text-align: center;
  font-size: 18px;
  margin-bottom: 6px;
}

.share-foot {
  margin-top: 18px;
  font-size: 12px;
  color: var(--muted);
}

.share-error {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  border: 1px solid #f6d3d5;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.6;
}

@media (max-width: 560px) {
  .share-wrap {
    padding: 18px 14px 32px;
  }

  .share-card > .card-body {
    padding: 18px 16px;
  }
}

/* 内容区放不下全部列时，先收起次要列（来源 / 渠道 / 更新时间） */
@media (max-width: 1500px) {
  table.data .wide-only {
    display: none;
  }
}

/* 窄屏笔记本：先收起自定义字段摘要与提交人，保留使用状态 / 结果 / 说明 / 时间 */
@media (max-width: 1280px) {
  table.data .col-summary,
  table.data .actor-only {
    display: none;
  }
}

/* 更窄：再收起结果与说明（详情弹窗仍可查看） */
@media (max-width: 1140px) {
  table.data .mid-only {
    display: none;
  }
}

@media (max-width: 1140px) {
  table.data th,
  table.data td {
    padding-left: 10px;
    padding-right: 10px;
  }

  table.data .cell-summary {
    max-width: 100px;
  }
}
