/* 渠道台 —— 微信带参数二维码管理后台
 * 设计基调:微信绿为脊,数据用等宽字体作“扫码读数”感,QR 定位角为签名图案。
 * 无外部字体/资源依赖,适配国内网络与无构建环境。 */

:root {
  --paper: #eef1ee;
  --surface: #ffffff;
  --ink: #13211b;
  --ink-soft: #5e6e66;
  --line: #dde5e0;
  --brand: #07c160;       /* 微信绿,用于色块/标记 */
  --brand-ink: #06924a;   /* 白底上可读的绿字 */
  --brand-wash: #e7f7ee;  /* 极浅绿,用于徽标/选中 */
  --danger: #c53a2b;
  --danger-wash: #fbeae7;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(19, 33, 27, .04), 0 8px 24px rgba(19, 33, 27, .06);

  --sans: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Source Han Sans SC",
    system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Consolas,
    "Courier New", monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- QR 定位角:签名图案 ---------- */
.qr-mark {
  width: 26px;
  height: 26px;
  border: 4px solid var(--ink);
  border-radius: 3px;
  position: relative;
  flex: none;
}
.qr-mark::before {
  content: "";
  position: absolute;
  inset: 5px;
  background: var(--brand);
  border-radius: 1px;
}

/* ---------- 顶部应用栏 ---------- */
.appbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.appbar__inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand__name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .2px;
}
.brand__name span { color: var(--brand-ink); }
.appbar__spacer { flex: 1; }
.appbar__user { color: var(--ink-soft); font-size: 13px; }
.appbar__user b { color: var(--ink); font-weight: 600; }

/* ---------- 布局容器 ---------- */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* ---------- 页头 ---------- */
.pagehead {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 28px;
}
.pagehead__titles { flex: 1; }
.pagehead h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.5px;
}
.pagehead__sub {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
}
.pagehead__sub b { font-family: var(--mono); color: var(--ink); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: filter .15s ease, background-color .15s ease, border-color .15s ease;
}
.btn:hover { text-decoration: none; }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { filter: brightness(.95); }
.btn--ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}
.btn--ghost:hover { border-color: var(--brand); color: var(--brand-ink); }
.btn--block { width: 100%; justify-content: center; }
.btn--lg { padding: 13px 22px; font-size: 15px; }

/* ---------- 卡片网格(列表) ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.card__body { padding: 18px 18px 0; display: flex; gap: 16px; }
.card__thumb {
  width: 92px;
  height: 92px;
  flex: none;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
  object-fit: contain;
  padding: 4px;
}
.card__thumb--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  font-size: 11px;
  text-align: center;
}
.card__info { min-width: 0; flex: 1; }
.card__name {
  margin: 2px 0 8px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  word-break: break-word;
}
.scene {
  display: inline-block;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--brand-ink);
  background: var(--brand-wash);
  padding: 2px 8px;
  border-radius: 999px;
}
.card__date {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--ink-soft);
}
.card__foot {
  margin-top: 16px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stat { display: flex; align-items: baseline; gap: 7px; }
.stat__num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1;
}
.stat__label { font-size: 12px; color: var(--ink-soft); }
.tag {
  font-size: 11px;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
}

/* ---------- 空状态 ---------- */
.empty {
  text-align: center;
  padding: 72px 24px;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.empty__motif {
  width: 76px;
  height: 76px;
  margin: 0 auto 22px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
}
.empty__motif .qr-mark { width: 100%; height: 100%; }
.empty__motif .qr-mark:nth-child(4) { visibility: hidden; }
.empty h2 { margin: 0 0 6px; font-size: 19px; }
.empty p { margin: 0 0 20px; color: var(--ink-soft); }

/* ---------- 表单 ---------- */
.formcard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  max-width: 560px;
}
.field { margin-bottom: 22px; }
.field > label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 7px;
}
.field__hint { font-weight: 400; color: var(--ink-soft); }
/* 打标签开关:复选框行(覆盖 .field > label 的 block 布局) */
.field > label.check {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 10px;
  cursor: pointer;
}
.check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
  cursor: pointer;
}
.input, .textarea {
  width: 100%;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
}
.textarea { resize: vertical; min-height: 110px; line-height: 1.5; }
.input:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-wash);
}

.file {
  display: block;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 18px;
  text-align: center;
  color: var(--ink-soft);
  cursor: pointer;
}
.file:hover { border-color: var(--brand); color: var(--brand-ink); }
.file input { display: none; }
.file__preview { margin-top: 14px; max-width: 160px; max-height: 160px; border-radius: var(--radius-sm); border: 1px solid var(--line); }

.formactions { display: flex; gap: 12px; align-items: center; margin-top: 4px; }

/* ---------- 登录 / 初始化 居中卡片 ---------- */
.auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth__card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
}
.auth__brand { display: flex; align-items: center; gap: 11px; margin-bottom: 6px; }
.auth__brand .brand__name { font-size: 17px; }
.auth__title { margin: 18px 0 4px; font-size: 22px; font-weight: 700; }
.auth__sub { margin: 0 0 26px; color: var(--ink-soft); font-size: 14px; }

/* ---------- Flash 提示 ---------- */
.flashes { margin-bottom: 22px; display: flex; flex-direction: column; gap: 10px; }
.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  border: 1px solid;
}
.flash--success { background: var(--brand-wash); border-color: #b6e6c9; color: var(--brand-ink); }
.flash--error { background: var(--danger-wash); border-color: #f0c4bd; color: var(--danger); }
.flash--info { background: #eef3f7; border-color: #d3e0ea; color: #355a76; }

/* ---------- 响应式 ---------- */
@media (max-width: 560px) {
  .pagehead { flex-direction: column; align-items: stretch; }
  .pagehead .btn { align-self: flex-start; }
  .card__body { flex-direction: column; }
  .card__thumb { width: 100%; height: 160px; }
}

/* ---------- 数据统计 ---------- */
/* 区段标题 */
.section-head { display: flex; align-items: baseline; gap: 10px; margin: 34px 0 14px; }
.section-head h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.2px; }
.section-head .section-sub { font-size: 13px; color: var(--ink-soft); }
.section-head .section-sub { font-family: var(--mono); }

/* 概览指标卡 */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 6px;
}
.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.metric__label { margin: 0 0 10px; font-size: 13px; color: var(--ink-soft); }
.metric__value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
}
.metric--accent { border-color: #b6e6c9; background: var(--brand-wash); }
.metric--accent .metric__value { color: var(--brand-ink); }

/* 卡片化表格 + 窄屏横向滚动 */
.table-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table thead th {
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .3px;
  text-align: left;
  padding: 12px 16px;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.table tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  color: var(--ink);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--brand-wash); }
.table .col-name { font-weight: 600; }
.table th.num, .table td.num {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.table .empty-row td { text-align: center; color: var(--ink-soft); padding: 30px; white-space: normal; }

/* 净增着色 */
.net-pos { color: var(--brand-ink); font-weight: 600; }
.net-neg { color: var(--danger); font-weight: 600; }
.net-zero { color: var(--ink-soft); }

/* 筛选条 */
.filters {
  display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.filters .field-inline { display: flex; flex-direction: column; }
.filters label { font-size: 12px; color: var(--ink-soft); margin-bottom: 6px; }
.filters .input { min-width: 160px; }

/* ---------- 素材选择弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal[hidden] { display: none; }

.modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(19, 33, 27, .45);
}

.modal__content {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 92%;
  max-width: 720px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.modal__header h3 { margin: 0; font-size: 17px; }

.modal__close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--ink-soft);
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.modal__close:hover { color: var(--ink); }

.modal__toolbar {
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
}

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

.modal__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  gap: 12px;
}
.modal__selected-name {
  font-size: 13px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.modal__actions { display: flex; gap: 10px; flex: none; }

/* 素材网格 */
.material-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 14px;
}
.material-item {
  position: relative;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  background: var(--paper);
  transition: border-color .15s ease;
}
.material-item:hover { border-color: var(--line); }
.material-item--selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-wash);
}
.material-item__thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}
.material-item__name {
  padding: 6px 8px;
  font-size: 11px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

/* 加载与空状态 */
.material-loading { text-align: center; padding: 24px; color: var(--ink-soft); }
.material-empty { text-align: center; padding: 32px; color: var(--ink-soft); }

/* 已选图片预览区 */
.image-preview-wrap { margin-bottom: 12px; }
.image-preview__actions { margin-top: 10px; display: flex; gap: 10px; }

/* ---------- 可达性 ---------- */
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
