:root {
  --bg: #f6f3ee;
  --panel: #ffffff;
  --ink: #2b2620;
  --muted: #7a7166;
  --line: #e6dfd4;
  --accent: #c8693b;
  --accent-ink: #ffffff;
  --ok: #2f7d4f;
  --ok-bg: #e5f3ea;
  --bad: #b23a2e;
  --bad-bg: #fbe9e6;
  --warn: #8a6100;
  --warn-bg: #fdf3d8;
  --chip: #f0ebe3;
  --chart: #c8693b;           /* 单系列图表色：已用 dataviz 校验脚本验过亮度和对比度 */
  --radius: 10px;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 16px rgba(60, 40, 20, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1916; --panel: #25221e; --ink: #ece6dc; --muted: #a59b8e; --line: #3a352e;
    --accent: #e08458; --accent-ink: #1b1916; --ok: #7fcf9c; --ok-bg: #1f3428; --bad: #f08a7e;
    --bad-bg: #3c2220; --warn: #e6c26b; --warn-bg: #3a3020; --chip: #302c26; --chart: #cf7349;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}
[hidden] { display: none !important; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 .6em; line-height: 1.3; }
h1 { font-size: 20px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* 登录 */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(360px, 100%); background: var(--panel); padding: 28px; border-radius: 14px; box-shadow: var(--shadow); display: grid; gap: 14px; }
label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
input, select { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* 按钮 */
.btn { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 8px; padding: 7px 14px; cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.small { padding: 3px 9px; font-size: 12.5px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* 框架 */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 20px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 16px; }
.brand span { color: var(--muted); font-weight: 400; margin-left: 4px; }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a { text-decoration: none; color: var(--muted); padding: 6px 12px; border-radius: 8px; }
.nav a.active { background: var(--chip); color: var(--ink); font-weight: 600; }
.who { display: flex; gap: 10px; align-items: center; color: var(--muted); }
.view { max-width: 1180px; margin: 0 auto; padding: 22px 16px 60px; }

.panel { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }
.muted { color: var(--muted); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12.5px; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; }

/* 标签 */
.tag { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; background: var(--chip); color: var(--muted); white-space: nowrap; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.live { background: var(--accent); color: var(--accent-ink); }

.msgs { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.msgs li { padding: 8px 12px; border-radius: 8px; }
.msgs.errors li { background: var(--bad-bg); color: var(--bad); }
.msgs.warnings li { background: var(--warn-bg); color: var(--warn); }
.error-text { color: var(--bad); margin: 0; min-height: 1em; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* 上传 */
.drop { border: 2px dashed var(--line); border-radius: 14px; padding: 36px 16px; text-align: center; background: var(--bg); cursor: pointer; transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--accent); background: var(--chip); }
.drop strong { display: block; font-size: 16px; margin-bottom: 6px; }
.file-list { margin: 12px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.busy { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 预览 */
.preview { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 18px; align-items: start; }
@media (max-width: 820px) { .preview { grid-template-columns: 1fr; } }
.canvas-box { background: repeating-conic-gradient(var(--chip) 0 25%, transparent 0 50%) 0 0 / 20px 20px; border-radius: 8px; overflow: hidden; }
.canvas-box canvas { display: block; width: 100%; height: auto; }
.tray { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.tray figure { margin: 0; background: var(--bg); border-radius: 8px; padding: 6px; text-align: center; font-size: 12px; }
.tray img { width: 100%; height: 56px; object-fit: contain; }
.tray figcaption { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; border: 0; background: transparent; color: var(--muted); padding: 5px 12px; cursor: pointer; }
.seg button.on { background: var(--chip); color: var(--ink); font-weight: 600; }

/* 频道 */
.level-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.level-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--bg); border-radius: 8px; flex-wrap: wrap; }
.level-list .grow { flex: 1; min-width: 120px; }
.ord { color: var(--muted); width: 1.6em; text-align: right; font-variant-numeric: tabular-nums; }

/* 弹窗与提示 */
.modal { position: fixed; inset: 0; background: rgba(20, 14, 8, .45); display: grid; place-items: center; z-index: 20; padding: 16px; }
.modal-card { background: var(--panel); border-radius: 14px; padding: 22px; width: min(460px, 100%); display: grid; gap: 14px; box-shadow: var(--shadow); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 10px; z-index: 30; max-width: calc(100% - 32px); }
.empty { padding: 26px; text-align: center; color: var(--muted); }
.panel h3 { margin-top: 18px; }
.who a { color: var(--muted); text-decoration: none; }
.who a:hover, .who a.active { color: var(--ink); text-decoration: underline; }
.account-form { display: grid; gap: 12px; max-width: 420px; }
#temp-password { font-size: 16px; padding: 6px 10px; background: var(--chip); border-radius: 6px; user-select: all; }

/* 数据看板 */
.filters { gap: 10px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 12px; }
.stat { background: var(--bg); border-radius: 10px; padding: 12px 14px; }
.stat-label { color: var(--muted); font-size: 12.5px; }
.stat-value { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.3; }
.stat-sub { color: var(--muted); font-size: 12px; }
.chart-box { position: relative; }
svg.chart { display: block; overflow: visible; }
.chart-box { min-height: 220px; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
svg.chart .tick { fill: var(--muted); font-size: 11px; }
svg.chart .val { fill: var(--ink); font-size: 11px; font-weight: 600; }
svg.chart .bar { fill: var(--chart); }
svg.chart .bar.hover { opacity: .78; }
svg.chart .hit { fill: transparent; cursor: default; outline: none; }
.tip { position: absolute; top: 0; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line);
  box-shadow: var(--shadow); border-radius: 8px; padding: 6px 10px; font-size: 12.5px; pointer-events: none; white-space: nowrap; z-index: 2; }
.tip strong { font-variant-numeric: tabular-nums; }
.ibar { display: inline-flex; align-items: center; gap: 8px; min-width: 130px; }
.ibar-track { flex: 1; height: 8px; background: var(--chip); border-radius: 4px; overflow: hidden; min-width: 60px; }
.ibar-fill { display: block; height: 100%; background: var(--chart); border-radius: 0 4px 4px 0; }
.ibar-val { font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }
.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.hbars li { display: grid; grid-template-columns: minmax(70px, 140px) 1fr auto; gap: 10px; align-items: center; }
.hb-track { height: 14px; }
.hb-fill { display: block; height: 100%; background: var(--chart); border-radius: 0 4px 4px 0; min-width: 2px; }
.hb-val { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.seg { flex-wrap: wrap; } .seg button { white-space: nowrap; }

/* 提示词清单（T-302） */
.prompt-text { white-space: pre-wrap; word-break: break-word; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font: 12.5px/1.5 ui-monospace, Menlo, Consolas, monospace; margin: 0; }
.json-edit { width: 100%; font: 12.5px/1.45 ui-monospace, Menlo, Consolas, monospace; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.offscreen { position: fixed; left: -9999px; top: 0; }
.prompt-fields { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 10px 0; }
@media (min-width: 900px) { .prompt-fields { grid-template-columns: 2fr 1fr; } .prompt-fields label.wide { grid-column: 1; } }
.field-text { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; resize: vertical; }
.field-text:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.prompt-full summary, .panel details summary { cursor: pointer; color: var(--muted); margin: 6px 0; }

/* 运营配置（T-320） */
.cfg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; align-items: end; }
.cfg-set { grid-column: 1 / -1; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px 12px; margin: 0; }
.cfg-set legend { color: var(--muted); font-size: 13px; padding: 0 4px; }
.cfg-grid input, .cfg-grid select { width: 100%; }
td input[type=number] { width: 7em; }
.seg a.btn { text-decoration: none; }
.seg .btn.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* 难度档位表（T-209） */
.nowrap { white-space: nowrap; }
input.narrow { width: 5em; }
