/* ==========================================================================
   YOUTAN 友摊 · 设计系统
   一个文件覆盖后台（admin）与移动端（mobile）两套皮肤
   ========================================================================== */

:root {
  --brand: #f4622a;
  --brand-dark: #d94e1a;
  --brand-soft: #fff4ee;
  --brand-ring: rgba(244, 98, 42, 0.18);

  --ink: #0f1b2d;
  --ink-2: #3b4859;
  --muted: #6b7787;
  --faint: #9aa4b2;
  --line: #e4e8ee;
  --line-soft: #eff2f6;
  --bg: #f5f7fa;
  --card: #ffffff;

  --success: #16a34a;
  --success-soft: #eaf7ef;
  --warn: #d98415;
  --warn-soft: #fff6e6;
  --danger: #dc2626;
  --danger-soft: #fdeeee;
  --info: #2563eb;
  --info-soft: #eef3ff;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(15, 27, 45, 0.05);
  --shadow: 0 4px 16px rgba(15, 27, 45, 0.07);
  --shadow-lg: 0 12px 40px rgba(15, 27, 45, 0.12);
  --sidebar-w: 236px;

  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

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

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

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }

code, .mono { font-family: var(--mono); font-size: 12.5px; }

::selection { background: var(--brand-ring); }

/* ---------------------------------------------------------------- 后台外壳 */
.admin-body { background: var(--bg); }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; z-index: 40;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px; border-bottom: 1px solid var(--line-soft);
}
.logo-mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, var(--brand), #ff9a5c);
  color: #fff; font-weight: 800; font-size: 15px;
  display: grid; place-items: center; letter-spacing: -0.5px;
}
.sidebar__brand b { display: block; font-size: 15px; letter-spacing: 0.02em; }
.sidebar__brand span { display: block; font-size: 11px; color: var(--muted); margin-top: -2px; }

.nav { padding: 12px 12px; overflow-y: auto; flex: 1; }
.nav__group { font-size: 11px; color: var(--faint); padding: 14px 10px 6px; letter-spacing: 0.08em; }
.nav__item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--r-sm); color: var(--ink-2);
  font-size: 13.5px; margin-bottom: 2px; cursor: pointer; transition: background 0.15s, color 0.15s;
}
.nav__item:hover { background: var(--line-soft); color: var(--ink); }
.nav__item.is-active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.nav__item svg { width: 17px; height: 17px; flex: none; opacity: 0.85; }
.nav__badge {
  margin-left: auto; background: var(--danger); color: #fff; font-size: 11px;
  padding: 1px 6px; border-radius: 20px; font-weight: 600;
}

.sidebar__foot { padding: 12px; border-top: 1px solid var(--line-soft); }
.who { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); background: var(--line-soft); }
.who .avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.who b { font-size: 13px; display: block; }
.who small { color: var(--muted); font-size: 11px; }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 14px 28px; display: flex; align-items: center; gap: 16px;
}
.topbar h1 { font-size: 18px; }
.topbar .sub { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.content { padding: 24px 28px 60px; }

/* ---------------------------------------------------------------- 组件 */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-sm);
}
.card__head {
  padding: 16px 20px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card__head h3 { font-size: 15px; }
.card__head .sub { color: var(--muted); font-size: 12px; }
.card__head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card__body { padding: 20px; }
.card__body.tight { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1200px) { .grid.cols-6 { grid-template-columns: repeat(3, minmax(0,1fr)); } .grid.cols-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 900px) { .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; } }

/* 指标卡 */
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; }
.stat__label { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.stat__value { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat__foot { font-size: 12px; color: var(--faint); margin-top: 4px; }
.stat--brand { background: linear-gradient(140deg, #fff, var(--brand-soft)); border-color: #ffd9c6; }
.stat--brand .stat__value { color: var(--brand-dark); }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 15px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: #fff; color: var(--ink-2); font-size: 13.5px; font-weight: 500;
  cursor: pointer; transition: all 0.15s; font-family: inherit; white-space: nowrap;
}
.btn:hover { border-color: #cfd6df; background: #fcfdfe; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn--ghost:hover { background: var(--line-soft); color: var(--ink); }
.btn--danger { background: #fff; border-color: #f3c7c7; color: var(--danger); }
.btn--danger:hover { background: var(--danger-soft); }
.btn--success { background: var(--success); border-color: var(--success); color: #fff; }
.btn--success:hover { filter: brightness(0.95); }
.btn--sm { padding: 5px 10px; font-size: 12.5px; }
.btn--lg { padding: 12px 22px; font-size: 15px; }
.btn--block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
/* 提交中的按钮：文字保持可读（不要把文字一起淡化到看不见，否则像"按钮空了/卡死"） */
.btn.is-busy { opacity: 0.85; cursor: progress; }
.btn.is-busy::after {
  content: ""; width: 11px; height: 11px; border-radius: 50%; display: inline-block;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: spin 0.7s linear infinite;
}

/* 表单 */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.input, .select, .textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r-sm);
  font-size: 14px; font-family: inherit; background: #fff; color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring);
}
.textarea { min-height: 84px; resize: vertical; line-height: 1.6; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7787' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filters .input, .filters .select { width: auto; min-width: 150px; }
.filters .grow { flex: 1; min-width: 200px; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th {
  text-align: left; padding: 11px 14px; background: #fafbfc;
  color: var(--muted); font-weight: 500; font-size: 12.5px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.tbl tbody tr:hover { background: #fcfdfe; }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl .num { font-variant-numeric: tabular-nums; }
table.tbl .right { text-align: right; }

/* 徽标 */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px;
  border-radius: 20px; font-size: 12px; font-weight: 500; line-height: 1.7;
  border: 1px solid transparent;
}
.badge--success { background: var(--success-soft); color: #12703a; border-color: #c7e9d4; }
.badge--warn { background: var(--warn-soft); color: #8a5a08; border-color: #f5dcb0; }
.badge--danger { background: var(--danger-soft); color: #a01b1b; border-color: #f3c7c7; }
.badge--info { background: var(--info-soft); color: #1b4bc0; border-color: #cdddfb; }
.badge--muted { background: #f2f4f7; color: #5a6572; border-color: #e3e7ec; }
.badge--brand { background: var(--brand-soft); color: var(--brand-dark); border-color: #ffd9c6; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }
.dot--live { background: var(--success); box-shadow: 0 0 0 0 rgba(22,163,74,0.5); animation: pulse 1.8s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(22,163,74,0); } 100% { box-shadow: 0 0 0 0 rgba(22,163,74,0); } }

/* 头像 / 缩略图 */
.avatar { border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); display: grid; place-items: center; font-weight: 600; font-size: 12px; flex: none; }
.thumb { width: 44px; height: 44px; border-radius: var(--r-sm); object-fit: cover; background: var(--line-soft); border: 1px solid var(--line); flex: none; }
.thumb--lg { width: 96px; height: 96px; }
.thumb--xl { width: 100%; height: 190px; border-radius: var(--r); }

.cell-main { display: flex; align-items: center; gap: 11px; }
.cell-main b { font-weight: 600; display: block; font-size: 13.5px; }
.cell-main small { color: var(--muted); font-size: 12px; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 4px; overflow-x: auto; }
.tabs a {
  padding: 10px 14px; font-size: 13.5px; color: var(--muted); border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap; font-weight: 500;
}
.tabs a:hover { color: var(--ink); }
.tabs a.is-active { color: var(--brand-dark); border-bottom-color: var(--brand); }

/* 空状态 */
/* 扁平单色图标（app/icons.py 生成的内联 SVG）。
   放这里而不是只放 mp.css：app.css 在所有端都加载（门户 / 后台 / 小程序），
   mp.css 只在小程序端。图标本身是「全局一套」，基础样式也应该跟着全局走 ——
   否则后台里的 SVG 是 display:inline + 基线对齐，纵向会多出一截空隙。 */
.ico {
  display: inline-block; flex: none;
  vertical-align: -0.15em;          /* 与中文字基线对齐 */
  transition: color 160ms ease, opacity 160ms ease;
}
.ico--lg { width: 34px; height: 34px; stroke-width: 1.5; }
.ico--xl { width: 46px; height: 46px; stroke-width: 1.4; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
/* 空态图标：原来是彩色 emoji，现在是单色 SVG，用 flex 居中而不是 font-size */
.empty .icon { display: flex; justify-content: center; margin-bottom: 12px; opacity: 0.5; line-height: 0; }
.empty b { display: block; color: var(--ink-2); margin-bottom: 4px; font-size: 14px; }

/* 分页 */
.pager { display: flex; align-items: center; gap: 6px; padding: 14px 18px; border-top: 1px solid var(--line-soft); }
.pager .info { margin-left: auto; color: var(--muted); font-size: 12.5px; }
.pager a, .pager span.pg {
  min-width: 32px; height: 32px; padding: 0 9px; border: 1px solid var(--line); border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px; background: #fff;
}
.pager a:hover { border-color: var(--brand); color: var(--brand-dark); }
.pager .is-current { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager .is-disabled { opacity: 0.45; pointer-events: none; }

/* 提示条 */
.alert { padding: 11px 14px; border-radius: var(--r-sm); font-size: 13px; display: flex; gap: 9px; align-items: flex-start; border: 1px solid transparent; }
.alert--info { background: var(--info-soft); border-color: #cdddfb; color: #1b4bc0; }
.alert--warn { background: var(--warn-soft); border-color: #f5dcb0; color: #8a5a08; }
.alert--danger { background: var(--danger-soft); border-color: #f3c7c7; color: #a01b1b; }
.alert--success { background: var(--success-soft); border-color: #c7e9d4; color: #12703a; }
.alert b { font-weight: 600; }

/* Toast */
#toast-host { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13.5px; box-shadow: var(--shadow-lg); animation: toast-in 0.22s ease;
  max-width: 90vw;
}
.toast--ok { background: #12703a; }
.toast--err { background: #b91c1c; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

/* 图表 */
.chart { width: 100%; height: 180px; display: block; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 5px; }

/* 弹层 */
.modal-host { position: fixed; inset: 0; background: rgba(15, 27, 45, 0.45); z-index: 100; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-host.is-open { display: flex; }
.modal { background: #fff; border-radius: var(--r-lg); width: 100%; max-width: 540px; max-height: 88vh; overflow: auto; box-shadow: var(--shadow-lg); }
.modal__head { padding: 18px 22px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; }
.modal__head h3 { font-size: 16px; }
.modal__head .close { margin-left: auto; cursor: pointer; color: var(--muted); font-size: 22px; line-height: 1; background: none; border: none; }
.modal__body { padding: 22px; }
.modal__foot { padding: 16px 22px; border-top: 1px solid var(--line-soft); display: flex; gap: 10px; justify-content: flex-end; }

/* 二维码展示 */
.qr-frame { background: #fff; padding: 14px; border: 1px solid var(--line); border-radius: var(--r); display: inline-block; }
.qr-frame img { display: block; width: 100%; max-width: 220px; height: auto; image-rendering: pixelated; }
.card-preview { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: #fff; }
.card-preview img { display: block; width: 100%; }

/* 进度条 */
.bar { height: 6px; border-radius: 99px; background: var(--line-soft); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }

/* 描述列表 */
.dl { display: grid; grid-template-columns: 132px 1fr; gap: 12px 16px; font-size: 13.5px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }

.kv-pill { display: inline-flex; gap: 6px; align-items: center; background: var(--line-soft); border-radius: var(--r-sm); padding: 5px 10px; font-size: 12.5px; margin: 0 6px 6px 0; }
.kv-pill b { font-weight: 600; }

/* ==========================================================================
   移动端
   ========================================================================== */
.m-body { background: #e9edf2; display: flex; justify-content: center; padding: 0; }
.phone {
  width: 100%; max-width: 440px; min-height: 100vh; background: var(--bg);
  position: relative; box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
}
@media (min-width: 700px) { .phone { margin: 24px 0; min-height: calc(100vh - 48px); border-radius: 24px; overflow: hidden; } }

.m-head {
  background: #fff; padding: 14px 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 20;
}
.m-head__back { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--line-soft); color: var(--ink-2); font-size: 16px; flex: none; }
.m-head h1 { font-size: 16px; flex: 1; }
.m-head .sub { font-size: 11.5px; color: var(--muted); font-weight: 400; }

.m-body-inner { padding: 18px 18px 110px; flex: 1; }
.m-foot {
  position: sticky; bottom: 0; background: rgba(255,255,255,0.96); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line); padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  display: flex; gap: 10px; z-index: 20;
}
.m-foot .btn { flex: 1; }

.m-hero { background: linear-gradient(150deg, var(--brand), #ff8a52 60%, #ffb27d); color: #fff; padding: 34px 22px 30px; }
.m-hero h1 { font-size: 25px; margin-bottom: 8px; letter-spacing: -0.02em; }
.m-hero p { margin: 0; opacity: 0.94; font-size: 14px; line-height: 1.7; }
.m-hero .slogan { margin-top: 18px; font-size: 15px; letter-spacing: 0.3em; opacity: 0.95; }

.m-section { margin-bottom: 16px; }
.m-section__title { font-size: 13px; color: var(--muted); margin: 0 2px 10px; display: flex; align-items: center; gap: 8px; }
.m-section__title .opt { color: var(--faint); font-size: 11.5px; }

.m-card { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.m-card + .m-card { margin-top: 12px; }

.uploader { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.uploader .slot {
  aspect-ratio: 1; border-radius: var(--r); border: 1.5px dashed #cbd3dd; background: #fff;
  display: grid; place-items: center; cursor: pointer; position: relative; overflow: hidden;
  color: var(--faint); font-size: 12px; text-align: center; transition: border-color 0.15s, background 0.15s;
}
.uploader .slot:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); }
.uploader .slot img { width: 100%; height: 100%; object-fit: cover; }
.uploader .slot .del {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%;
  background: rgba(15,27,45,0.65); color: #fff; display: grid; place-items: center;
  font-size: 13px; border: none; cursor: pointer;
}
.uploader .slot .plus { font-size: 24px; line-height: 1; }
.uploader .slot .flag { position: absolute; left: 4px; bottom: 4px; background: rgba(220,38,38,0.9); color: #fff; font-size: 10px; padding: 1px 5px; border-radius: 4px; }

.m-step { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; }
.m-step i { width: 22px; height: 22px; border-radius: 50%; background: var(--line-soft); color: var(--muted); font-size: 12px; display: grid; place-items: center; font-style: normal; flex: none; }
.m-step i.on { background: var(--brand); color: #fff; }
.m-step i.done { background: var(--success-soft); color: var(--success); }
.m-step .line { flex: 1; height: 2px; background: var(--line); }
.m-step .line.on { background: var(--brand); }

/* 商品行 */
.prow { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.prow:last-child { border-bottom: none; }
.prow .name { flex: 1; font-size: 14px; }
.prow .price { font-weight: 600; color: var(--brand-dark); font-variant-numeric: tabular-nums; }
.prow .conf { font-size: 11px; color: var(--warn); }
.prow input.name-in { flex: 1; }
.prow input.price-in { width: 78px; text-align: right; }

.m-stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.m-stat { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 12px; text-align: center; }
.m-stat b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.m-stat span { font-size: 11.5px; color: var(--muted); }

.m-list-item { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line-soft); }
.m-list-item:last-child { border-bottom: none; }
.m-list-item .arrow { color: var(--faint); }
.m-list-item .t { flex: 1; font-size: 14px; }
.m-list-item .t small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }

/* AI 处理动画 */
.ai-loading { text-align: center; padding: 40px 20px; }
.ai-orb {
  width: 92px; height: 92px; margin: 0 auto 24px; border-radius: 50%;
  background: conic-gradient(from 0deg, var(--brand), #ffc49a, var(--brand));
  animation: spin 2.4s linear infinite; position: relative;
}
.ai-orb::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: #fff; }
.ai-orb span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 30px; z-index: 2; }
@keyframes spin { to { transform: rotate(360deg); } }
.ai-steps { list-style: none; padding: 0; margin: 0 auto; max-width: 290px; text-align: left; }
.ai-steps li { display: flex; align-items: center; gap: 10px; padding: 8px 0; color: var(--faint); font-size: 13.5px; }
.ai-steps li.on { color: var(--ink); }
.ai-steps li .tick { width: 19px; height: 19px; border-radius: 50%; border: 1.5px solid currentColor; display: grid; place-items: center; font-size: 11px; flex: none; }
.ai-steps li.done .tick { background: var(--success); border-color: var(--success); color: #fff; }

/* 置信度 */
.conf-bar { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.conf-bar .bar { flex: 1; height: 4px; }
.conf-bar .bar > i.low { background: var(--warn); }
.conf-bar .bar > i.high { background: var(--success); }

/* 悬浮操作 */
.m-fab { position: fixed; right: calc(50% - 200px + 16px); bottom: 88px; width: 52px; height: 52px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; box-shadow: var(--shadow-lg); border: none; font-size: 22px; cursor: pointer; z-index: 25; }
@media (max-width: 480px) { .m-fab { right: 16px; } }

.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline__item { position: relative; padding-bottom: 16px; }
.timeline__item::before { content: ""; position: absolute; left: -22px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--brand-soft); }
.timeline__item .t { font-size: 13.5px; font-weight: 500; }
.timeline__item .d { font-size: 12px; color: var(--muted); }

/* 开发者调试条 */
.devbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  background: rgba(15, 27, 45, 0.94); color: #fff; font-size: 12px;
  display: flex; align-items: center; gap: 10px; padding: 7px 14px; flex-wrap: wrap;
  backdrop-filter: blur(6px);
}
.devbar b { color: #ffb27d; font-weight: 600; }
.devbar .sp { margin-left: auto; }
.devbar a { color: #9ecbff; }
.devbar button { background: rgba(255,255,255,0.12); border: none; color: #fff; border-radius: 6px; padding: 3px 9px; font-size: 11.5px; cursor: pointer; font-family: inherit; }
.devbar button:hover { background: rgba(255,255,255,0.22); }
body.has-devbar { padding-bottom: 38px; }

/* 门户页 */
.portal { max-width: 1080px; margin: 0 auto; padding: 40px 24px 80px; }
.portal__hero { display: flex; align-items: center; gap: 18px; margin-bottom: 8px; }
.portal__hero h1 { font-size: 30px; letter-spacing: -0.02em; }
.portal__hero p { color: var(--muted); margin: 4px 0 0; }

/* 门户分节：标题 + 副标题 + 内容，所有区块共用同一套间距与栅格 */
.portal__section { margin-bottom: 34px; }
.portal__section:last-child { margin-bottom: 0; }
.portal__head {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  margin-bottom: 14px; padding-bottom: 9px; border-bottom: 1px solid var(--line);
}
.portal__head h3 { font-size: 15px; }
.portal__head .hint { color: var(--muted); font-size: 12.5px; }
.portal__head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* 入口卡：等高、内文底部对齐 */
.entry {
  display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line);
  border-radius: var(--r); padding: 20px; transition: border-color .16s, box-shadow .16s, transform .16s;
  height: 100%; min-height: 176px;
}
.entry:hover { border-color: var(--brand); box-shadow: var(--shadow); transform: translateY(-2px); }
.entry .ico { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  font-size: 19px; margin-bottom: 12px; background: var(--brand-soft);
  color: var(--brand-dark); }   /* 图标是单色线稿，跟随品牌色而不是正文字色 */
.entry:hover .ico { background: #ffe9dd; }
.entry b { display: block; font-size: 15px; margin-bottom: 4px; }
.entry small { color: var(--muted); line-height: 1.6; display: block; }
.entry code { background: var(--line-soft); padding: 1px 6px; border-radius: 5px; font-size: 11.5px; color: var(--brand-dark); }
.entry__foot {
  margin-top: auto; padding-top: 12px; font-size: 12px; color: var(--muted); line-height: 1.65;
}
.entry__foot .tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px;
  background: var(--line-soft); border-radius: 6px; padding: 2px 7px; margin: 0 5px 5px 0; color: var(--ink-2);
}
.entry--accent { border-color: #ffd9c6; background: linear-gradient(150deg, #fff, var(--brand-soft)); }

/* 门户里的两块信息卡：高度一致、卡片内头尾对齐 */
.portal__pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
@media (max-width: 900px) { .portal__pair { grid-template-columns: 1fr; } }
.portal__pair > .card { display: flex; flex-direction: column; }
.portal__pair > .card > .card__body { flex: 1; }
.panel-title {
  font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px;
  padding-bottom: 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line-soft);
}
.panel-title .right { margin-left: auto; font-size: 12px; }

/* 账号行：与后台列表保持同一节奏 */
.acct-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}
.acct-row:last-of-type { border-bottom: none; }
.acct-row .avatar { width: 34px; height: 34px; font-size: 13px; }
.acct-row .t { flex: 1; min-width: 0; }
.acct-row .t b { display: block; font-size: 13.5px; }
.acct-row .t small { color: var(--muted); font-size: 12px; }
.acct-row .t code { color: var(--brand-dark); }

.flow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.flow span { background: #fff; border: 1px solid var(--line); padding: 5px 11px; border-radius: 999px; }
.flow i { color: var(--faint); font-style: normal; }

/* 打印 */
@media print {
  .sidebar, .topbar, .no-print, .devbar { display: none !important; }
  .main { margin-left: 0; }
}

/* ==========================================================================
   AI Agent Center
   --------------------------------------------------------------------------
   全部沿用后台既有语汇（白卡 / 浅灰底 / 蓝主色 / 现有按钮与徽标）。
   刻意**不做**「AI 科技风」（§3.1）：Agent 应该看起来像后台的原生业务模块。
   唯一新增的颜色语义是"高风险"——统一用红（--danger），别处不使用。
   ========================================================================== */

/* Agent 状态行（工作台） */
.agent-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.agent-row:last-child { border-bottom: none; }
.agent-row__ico {
  flex: none; width: 34px; height: 34px; border-radius: var(--r-sm);
  display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-dark);
}
.agent-row__main { flex: 1; min-width: 0; }
.agent-row__main b { display: block; font-size: 14px; }
.agent-row__main span { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* 待处理 / 进行中 的行 */
.need-row { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.need-row:last-child { border-bottom: none; }
.need-row__main { flex: 1; min-width: 0; }
.need-row__main b { display: block; font-size: 13.5px; }
.need-row__main span { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.need-row.is-danger .need-row__main b { color: var(--danger); }

/* 最近活动 */
.feed-row { display: flex; align-items: baseline; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.feed-row:last-child { border-bottom: none; }
.feed-row__time { flex: none; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.feed-row__agent { flex: none; min-width: 62px; color: var(--ink-2); font-weight: 500; font-size: 12.5px; }
.feed-row__text { flex: 1; color: var(--ink-2); }

/* 任务详情：键值块与预格式文本 */
.pre { white-space: pre-wrap; word-break: break-word; font-size: 13px; line-height: 1.65; color: var(--ink-2); }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.kv:last-child { border-bottom: none; }
.kv > label { color: var(--muted); font-size: 12.5px; padding-top: 1px; }
.kv > div { min-width: 0; font-size: 13px; }

/* 执行计划与 Timeline：复用既有 .timeline 的竖轴与圆点，只补内部排版 */
ol.timeline { list-style: none; margin: 0; }
.timeline__item { display: block; }
.timeline__item--error::before { background: var(--danger); box-shadow: 0 0 0 2px #fdecec; }
.timeline__item--plan::before { background: var(--brand); }
.timeline__item--tool_call::before { background: #6366f1; box-shadow: 0 0 0 2px #eef0fe; }
.timeline__item--tool_result::before { background: var(--success); box-shadow: 0 0 0 2px var(--success-soft); }
.timeline__item--approval::before { background: var(--warn); box-shadow: 0 0 0 2px var(--warn-soft); }
.timeline__time { float: right; color: var(--faint); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.timeline__ico { color: var(--muted); vertical-align: -3px; margin-right: 6px; }
.timeline__body { display: inline-block; width: calc(100% - 26px); vertical-align: top; }
.timeline__title { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.timeline__title code { font-size: 12px; color: var(--ink-2); }
.timeline__text { font-size: 13px; line-height: 1.6; margin-top: 4px; white-space: pre-wrap; word-break: break-word; }
.timeline__detail { margin-top: 5px; }
.timeline__detail summary { font-size: 12px; color: var(--muted); cursor: pointer; }
.timeline__detail pre {
  margin: 6px 0 0; padding: 9px 11px; background: #f7f9fb; border: 1px solid var(--line);
  border-radius: var(--r-sm); font-size: 12px; max-height: 260px; overflow: auto;
  white-space: pre-wrap; word-break: break-word;
}

/* 审批卡片：只有"待处理"才用红色左边框 —— 高风险只用红色强调（§42） */
.approval-card { border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 14px; overflow: hidden; background: #fff; }
.approval-card.is-pending { border-left: 3px solid var(--danger); }
.approval-card__head {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px;
  background: #fafbfc; border-bottom: 1px solid var(--line-soft); font-size: 13.5px;
}
.approval-card__body { padding: 6px 14px 10px; }
.approval-card__foot {
  display: flex; gap: 8px; align-items: center; padding: 11px 14px;
  border-top: 1px solid var(--line-soft); background: #fcfdfe;
}

/* 知识库条目 */
.kb-item { border: 1px solid var(--line); border-radius: var(--r-sm); margin-bottom: 8px; background: #fff; }
.kb-item.is-off { opacity: .6; }
.kb-item > summary {
  display: flex; align-items: center; gap: 10px; padding: 11px 13px; cursor: pointer;
  font-size: 13.5px; list-style: none;
}
.kb-item > summary::-webkit-details-marker { display: none; }
.kb-item__title { font-weight: 500; }
.kb-item__ops { margin-left: auto; display: flex; gap: 6px; }
.kb-item__body { padding: 0 13px 12px; border-top: 1px solid var(--line-soft); }
.kb-item__pre {
  margin: 10px 0 0; padding: 11px 13px; background: #f7f9fb; border: 1px solid var(--line);
  border-radius: var(--r-sm); font-size: 12.5px; line-height: 1.7; max-height: 340px; overflow: auto;
  white-space: pre-wrap; word-break: break-word;
}

/* Decision Log 条目 */
.decision-row { padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.decision-row:last-child { border-bottom: none; }
.decision-row__head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.decision-row__head b { font-weight: 600; }
.decision-row__body { font-size: 13px; color: var(--ink-2); margin-top: 5px; line-height: 1.6; }
.decision-row__reason { font-size: 12.5px; color: var(--muted); margin-top: 4px; line-height: 1.6; }
.decision-row__reason .ico { vertical-align: -2px; margin-right: 3px; }

/* 多选器（工具授权 / 知识范围 / 关联知识） */
.picker { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.picker__item {
  display: flex; align-items: center; gap: 8px; padding: 7px 11px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff;
  font-size: 12.5px; cursor: pointer; user-select: none;
}
.picker__item:hover { border-color: var(--brand-ring); background: #fffaf7; }
.picker__item input { margin: 0; }
.picker__item code { font-size: 12px; color: var(--ink-2); }
.picker__item--inline { padding: 6px 10px; }

/* 空提示 */
.empty-hint { display: flex; align-items: center; gap: 8px; padding: 18px 0; color: var(--muted); font-size: 13px; }
.table__empty { text-align: center; color: var(--muted); padding: 28px 0 !important; }

/* 新增知识 / 决策表单里的字段与既有后台保持一致 */
.field .req { color: var(--danger); }

/* 日志表格里的错误行 */
tr.is-danger-row td { background: #fff8f8; }

/* 开关（工具运行期启用状态） */
.switch { position: relative; display: inline-block; width: 38px; height: 21px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; background: #cfd6de; border-radius: 999px;
  transition: background .18s ease; cursor: pointer;
}
.switch span::after {
  content: ""; position: absolute; left: 2px; top: 2px; width: 17px; height: 17px;
  background: #fff; border-radius: 50%; transition: transform .18s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(17px); }

/* 新建任务的模式切换：复用 .tabs 的观感，但元素是 button */
.tabs button.tab {
  padding: 10px 14px; font-size: 13.5px; color: var(--muted);
  border: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
  background: none; font-family: inherit; cursor: pointer; font-weight: 500;
}
.tabs button.tab:hover { color: var(--ink); }
.tabs button.tab.is-active { color: var(--brand-dark); border-bottom-color: var(--brand); }
