/* 运营后台的结构样式。颜色、字号、圆角、间距全部取 tokens.css 的变量（深浅色由它按系统切换），这里不写死颜色。
   桌面布局：左侧导航 + 右侧内容；窄屏只保证不横向滚动 */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font: var(--size-s14)/var(--lineHeight-body) -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
}
[hidden] { display: none !important; }
a { color: var(--acc); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: var(--weight-medium); margin: 0; }
.muted { color: var(--mut); }
.dim { color: var(--dim); }
.num { font-variant-numeric: tabular-nums; letter-spacing: var(--tracking-numberLoose); white-space: nowrap; }
.pre { white-space: pre-wrap; word-break: break-word; }
.nowrap { white-space: nowrap; }
.boot { padding: 40vh 0 0; text-align: center; color: var(--dim); }

/* ---------- 按钮与表单 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-s6);
  height: 34px; padding: 0 var(--space-s14);
  border: 1px solid var(--line); border-radius: var(--radius-r8);
  background: var(--surf); color: var(--txt);
  font: inherit; font-size: var(--size-s13); cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--accHover); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accFill); border-color: var(--accFill); color: var(--onAcc); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--warn); border-color: var(--warn); }
.btn.small { height: 28px; padding: 0 var(--space-s10); font-size: var(--size-s12); }
.btn.wide { width: 100%; }
.link { background: none; border: 0; padding: 0; color: var(--acc); font: inherit; font-size: var(--size-s12); cursor: pointer; }
.link:hover { text-decoration: underline; }
input, select, textarea {
  font: inherit; font-size: var(--size-s14); color: var(--txt);
  background: var(--surf); border: 1px solid var(--line); border-radius: var(--radius-r8);
  padding: 0 var(--space-s10); height: 34px;
}
textarea { height: auto; min-height: 96px; padding: var(--space-s8) var(--space-s10); resize: vertical; width: 100%; line-height: var(--lineHeight-body); }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .nav a:focus-visible { outline: 2px solid var(--a7); outline-offset: 1px; }
.field { display: flex; flex-direction: column; gap: var(--space-s4); font-size: var(--size-s12); color: var(--mut); }
.field input { height: 40px; font-size: var(--size-s15); }
.field-row { display: flex; gap: var(--space-s8); align-items: flex-end; }
.field-row .btn { height: 40px; }
.grow { flex: 1; min-width: 0; }

/* ---------- 登录 ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: var(--space-s20); }
.login-card {
  width: min(380px, 100%);
  background: var(--surf); border: 1px solid var(--line); border-radius: var(--radius-r14);
  padding: var(--space-s22) var(--space-s22) var(--space-s18);
  display: flex; flex-direction: column; gap: var(--space-s14);
}
.login-card h1 { font-size: var(--size-s22); }
.login-card p { margin: 0; }
.login-card form { display: flex; flex-direction: column; gap: var(--space-s14); }
.msg { min-height: 1.5em; font-size: var(--size-s13); color: var(--mut); }
.msg.error { color: var(--warn); }

/* ---------- 框架 ---------- */
.app { display: grid; grid-template-columns: 200px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: var(--space-s20);
  padding: var(--space-s20) var(--space-s12);
  background: var(--surf2); border-right: 1px solid var(--line);
}
.brand { font-size: var(--size-s18); font-weight: var(--weight-medium); padding: 0 var(--space-s10); display: flex; flex-direction: column; }
.brand small { font-size: var(--size-s12); color: var(--dim); font-weight: var(--weight-regular); letter-spacing: var(--tracking-label); }
.nav { display: flex; flex-direction: column; gap: var(--space-s2); }
.nav a {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-s8) var(--space-s10); border-radius: var(--radius-r8);
  color: var(--lt); font-size: var(--size-s14);
}
.nav a:hover { background: var(--accHover); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--a9); color: var(--a3); font-weight: var(--weight-medium); }
.badge {
  min-width: 20px; height: 20px; padding: 0 var(--space-s6); border-radius: 10px;
  background: var(--warn); color: var(--surf); font-size: var(--size-s11); line-height: 20px; text-align: center;
}
.who { margin-top: auto; padding: 0 var(--space-s10); font-size: var(--size-s12); color: var(--mut); display: flex; flex-direction: column; gap: var(--space-s4); align-items: flex-start; }
.main { padding: var(--space-s22) calc(var(--space-s14) * 2); max-width: 1400px; width: 100%; outline: none; }
.head { display: flex; align-items: center; gap: var(--space-s12); flex-wrap: wrap; margin-bottom: var(--space-s18); }
.head h2 { font-size: var(--size-s22); }
.head .spacer { flex: 1; }
.section { margin-top: var(--space-s22); }
.section > h3 { font-size: var(--size-s15); margin-bottom: var(--space-s10); color: var(--lt); }
.banner { padding: var(--space-s10) var(--space-s14); border-radius: var(--radius-r10); border: 1px solid var(--warn); color: var(--warn); margin-bottom: var(--space-s14); font-size: var(--size-s13); }
.empty { padding: var(--space-s22); text-align: center; color: var(--dim); }

/* ---------- 标签页 ---------- */
.tabs { display: flex; gap: var(--space-s4); flex-wrap: wrap; }
.tabs a { padding: var(--space-s4) var(--space-s12); border-radius: var(--radius-r20); color: var(--lt); border: 1px solid var(--line); font-size: var(--size-s13); }
.tabs a:hover { text-decoration: none; background: var(--accHover); }
.tabs a[aria-current="page"] { background: var(--accFill); border-color: var(--accFill); color: var(--onAcc); }

/* ---------- 数字卡 ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--space-s12); }
.card { background: var(--surf); border: 1px solid var(--line); border-radius: var(--radius-r12); padding: var(--space-s14) var(--space-s16); display: flex; flex-direction: column; gap: var(--space-s6); }
.card .label { font-size: var(--size-s12); color: var(--mut); letter-spacing: var(--tracking-label); }
.card .big { font-size: var(--size-s28); font-weight: var(--weight-medium); line-height: var(--lineHeight-tight); }
.card .lines { display: flex; flex-direction: column; gap: var(--space-s2); font-size: var(--size-s13); color: var(--lt); }
.card .lines div { display: flex; justify-content: space-between; gap: var(--space-s10); }
.card .lines span:first-child { color: var(--mut); }
.card.alert { border-color: var(--warn); }
.card.alert .big { color: var(--warn); }
a.card { color: inherit; }
a.card:hover { text-decoration: none; background: var(--surf2); }

/* ---------- 折线图 ---------- */
.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--space-s12); }
.chart { background: var(--surf); border: 1px solid var(--line); border-radius: var(--radius-r12); padding: var(--space-s12) var(--space-s14) var(--space-s8); }
.chart h4 { margin: 0 0 var(--space-s6); font-size: var(--size-s13); font-weight: var(--weight-medium); color: var(--lt); display: flex; justify-content: space-between; }
.chart h4 span { color: var(--mut); font-weight: var(--weight-regular); }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid { stroke: var(--row); stroke-width: 1; }
.chart-area { fill: var(--a9); stroke: none; }
.chart-line { fill: none; stroke: var(--acc); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { fill: var(--surf); stroke: var(--acc); stroke-width: 1.5; }
.chart-dot:hover { fill: var(--acc); }
.chart-label { fill: var(--dim); font-size: 10px; font-variant-numeric: tabular-nums; }

/* ---------- 表格 ---------- */
.table-wrap { background: var(--surf); border: 1px solid var(--line); border-radius: var(--radius-r12); overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--size-s13); }
th, td { padding: var(--space-s8) var(--space-s12); text-align: left; border-bottom: 1px solid var(--row); vertical-align: top; }
th { position: sticky; top: 0; background: var(--surf2); color: var(--mut); font-weight: var(--weight-medium); font-size: var(--size-s12); white-space: nowrap; z-index: 1; }
tr:last-child td { border-bottom: 0; }
td.right, th.right { text-align: right; }
td .sub { display: block; font-size: var(--size-s12); color: var(--dim); }
td.title { max-width: 320px; }
td.actions { white-space: nowrap; }
td.actions .btn + .btn { margin-left: var(--space-s6); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--accHover); }
tr.selected td { background: var(--a9); }
.more { display: flex; justify-content: center; padding: var(--space-s12); }

/* ---------- 小标签 ---------- */
.chip { display: inline-block; padding: 0 var(--space-s8); border-radius: var(--radius-r20); font-size: var(--size-s12); line-height: 20px; border: 1px solid var(--line); color: var(--lt); white-space: nowrap; }
.chip.accent { border-color: var(--a7); color: var(--a3); background: var(--a9); }
.chip.warn { border-color: var(--warn); color: var(--warn); }
.chip.gold { border-color: var(--gold); color: var(--gold); }
.chip.muted { color: var(--dim); }

/* ---------- 反馈：列表 + 详情 ---------- */
.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: var(--space-s14); align-items: start; }
.list { display: flex; flex-direction: column; gap: var(--space-s8); }
.item { background: var(--surf); border: 1px solid var(--line); border-radius: var(--radius-r10); padding: var(--space-s10) var(--space-s12); cursor: pointer; display: flex; flex-direction: column; gap: var(--space-s4); text-align: left; font: inherit; color: inherit; width: 100%; }
.item:hover { background: var(--surf2); }
.item[aria-current="true"] { border-color: var(--a7); background: var(--a9); }
.item .meta { display: flex; gap: var(--space-s6); align-items: center; flex-wrap: wrap; font-size: var(--size-s12); color: var(--mut); }
.item .preview { font-size: var(--size-s13); color: var(--txt); display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.detail { position: sticky; top: var(--space-s16); background: var(--surf); border: 1px solid var(--line); border-radius: var(--radius-r12); padding: var(--space-s16) var(--space-s18); display: flex; flex-direction: column; gap: var(--space-s14); max-height: calc(100vh - 32px); overflow: auto; }
.detail .content { font-size: var(--size-s15); line-height: var(--lineHeight-body); }
.kv { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: var(--space-s4) var(--space-s12); font-size: var(--size-s13); }
.kv dt { color: var(--mut); }
.kv dd { margin: 0; word-break: break-all; }
.reply-box { display: flex; flex-direction: column; gap: var(--space-s8); }
.reply-box .row { display: flex; gap: var(--space-s8); align-items: center; }
.reply-sent { background: var(--surf2); border-radius: var(--radius-r8); padding: var(--space-s10) var(--space-s12); font-size: var(--size-s13); }

/* ---------- 筛选条 ---------- */
.filters { display: flex; gap: var(--space-s8); flex-wrap: wrap; align-items: center; margin-bottom: var(--space-s12); }
.filters input { width: 260px; }

/* ---------- 对话框与提示 ---------- */
.dialog { border: 1px solid var(--line); border-radius: var(--radius-r14); background: var(--surf); color: var(--txt); padding: var(--space-s20); width: min(460px, calc(100vw - 32px)); }
.dialog::backdrop { background: var(--scrim); }
.dialog h3 { font-size: var(--size-s18); margin-bottom: var(--space-s10); }
.dialog .body { color: var(--lt); font-size: var(--size-s14); white-space: pre-wrap; }
.dialog textarea { margin-top: var(--space-s12); }
.dialog .error { color: var(--warn); font-size: var(--size-s13); min-height: 1.4em; margin-top: var(--space-s6); }
.dialog .buttons { display: flex; justify-content: flex-end; gap: var(--space-s8); margin-top: var(--space-s14); }
.toast {
  position: fixed; left: 50%; bottom: var(--space-s22); transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 32px));
  background: var(--txt); color: var(--bg); padding: var(--space-s10) var(--space-s16); border-radius: var(--radius-r10);
  font-size: var(--size-s13); box-shadow: 0 6px 24px var(--shd); z-index: 10;
}
.toast.error { background: var(--warn); color: var(--surf); }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); padding: var(--space-s10) var(--space-s12); }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .who { margin: 0 0 0 auto; }
  .main { padding: var(--space-s16); }
  .split { grid-template-columns: 1fr; }
  .detail { position: static; max-height: none; }
  .filters input { width: 100%; }
}
