/* ============================================================
   设计系统 - 所有组件类名以 ds- 为前缀
   新代码必须用设计系统类名，禁止写 inline style
   ============================================================ */

:root {
  --primary: #1B2A4A;
  --accent: #E63946;
  --success: #2E7D32;
  --warning: #FF9800;
  --danger: #c0392b;
  --bg: #f5f6fa;
  --card-bg: #fff;
  --text: #333;
  --muted: #888;
  --border: #e8e8e8;
  --hover: #f8f9fa;
  --radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* ---------- 导航栏 ---------- */
.ds-navbar {
  display: flex;
  align-items: center;
  background: var(--primary);
  color: #fff;
  padding: 0 1.5em;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.ds-navbar-brand { font-size: 18px; font-weight: 700; margin-right: 2em; }
.ds-navbar-menu { display: flex; gap: .5em; flex: 1; }
.ds-navbar-menu a {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  padding: .5em 1em;
  border-radius: var(--radius);
  transition: all .2s;
}
.ds-navbar-menu a:hover,
.ds-navbar-menu a.active { color: #fff; background: rgba(255,255,255,0.15); }
.ds-navbar-user { font-size: 13px; color: rgba(255,255,255,0.8); }

/* ---------- 主内容 ---------- */
.ds-main { padding: 1.5em; max-width: 1400px; margin: 0 auto; }

/* ---------- 卡片 ---------- */
.ds-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.2em 1.5em;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 1em;
}
.ds-card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: .8em;
  padding-bottom: .5em;
  border-bottom: 1px solid var(--border);
}

/* ---------- 按钮 ---------- */
.ds-btn {
  display: inline-flex;
  align-items: center;
  gap: .4em;
  padding: .5em 1.2em;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  transition: all .2s;
}
.ds-btn-primary { background: var(--primary); color: #fff; }
.ds-btn-primary:hover { opacity: .85; }
.ds-btn-danger { background: var(--accent); color: #fff; }
.ds-btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }

/* ---------- 表格 ---------- */
.ds-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.ds-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--hover);
  text-align: left;
  padding: .6em .8em;
  font-weight: 600;
  font-size: 13px;
  border-bottom: 2px solid var(--border);
}
.ds-table td {
  padding: .5em .8em;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.ds-table tr:hover { background: var(--hover); }

/* ---------- 拖拽把手 ---------- */
.col-resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  width: 4px;
  height: 100%;
  cursor: col-resize;
  background: rgba(0,0,0,0.08);
}

/* ---------- 输入框清空按钮 ---------- */
.inp-clear-wrap { position: relative; display: inline-flex; align-items: center; }
.inp-clear-btn {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: #aaa;
  cursor: pointer;
  font-size: 16px;
  display: none;
}
.inp-clear-wrap input:not(:placeholder-shown) + .inp-clear-btn { display: block; }

/* ---------- 徽章 ---------- */
.ds-badge {
  display: inline-block;
  padding: .15em .6em;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
.ds-badge-success { background: #e8f5e9; color: var(--success); }
.ds-badge-warning { background: #fff3e0; color: #e65100; }
.ds-badge-danger { background: #fef2f2; color: var(--danger); }

/* ---------- 提示 ---------- */
.ds-toast {
  position: fixed;
  top: 72px;
  right: 1.5em;
  background: var(--primary);
  color: #fff;
  padding: .8em 1.5em;
  border-radius: var(--radius);
  z-index: 9999;
  animation: slideIn .3s ease;
}
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } }

/* ---------- 布局工具类 ---------- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: .5em; }
.gap-md { gap: 1em; }
.gap-lg { gap: 1.5em; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1em; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1em; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1em; }

/* ============================================================
   工作台 · 运营驾驶舱（仅工作台使用；以上全局类不受影响）
   ============================================================ */
:root {
  --solar: #F5A524;
  --signal: #16A34A;
  --ink: #141E33;
  --ink-2: #22314F;
  --console-line: rgba(255,255,255,.10);
}

/* 表格数字：等宽数字，收紧字距，仪表读数感 */
.ds-num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; letter-spacing: -.01em; }

.ds-eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted);
}

/* 驾驶舱标题栏 */
.ds-console-head {
  display: flex; align-items: baseline; justify-content: space-between;
  flex-wrap: wrap; gap: .5em; margin: .2em 0 1.1em;
}
.ds-console-head h1 { font-size: 21px; font-weight: 700; letter-spacing: .02em; color: var(--primary); }
.ds-console-head .meta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* 今日主读数面板（signature） */
.ds-readout {
  position: relative; overflow: hidden; color: #fff;
  border-radius: 14px; padding: 1.6em 1.8em; margin-bottom: 1em;
  background:
    radial-gradient(130% 150% at 100% 0%, rgba(245,165,36,.20), transparent 55%),
    linear-gradient(160deg, var(--ink) 0%, var(--ink-2) 100%);
}
.ds-readout::before {
  content: ""; position: absolute; left: 0; top: 0; height: 3px; width: 100%;
  background: linear-gradient(90deg, var(--solar), transparent 62%);
}
.ds-readout-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.5em; flex-wrap: wrap; }
.ds-readout-headline .ds-eyebrow { color: rgba(255,255,255,.55); }
.ds-readout-num { font-size: 46px; font-weight: 700; line-height: 1.08; margin-top: .12em;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.ds-readout-sub { margin-top: .35em; font-size: 13px; color: rgba(255,255,255,.62); }

.ds-spark { width: 210px; max-width: 42vw; height: 58px; }
.ds-spark svg { width: 100%; height: 100%; display: block; }

.ds-tiles {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 1px;
  margin-top: 1.4em; background: var(--console-line);
  border: 1px solid var(--console-line); border-radius: 10px; overflow: hidden;
}
.ds-tile { background: rgba(255,255,255,.015); padding: .75em 1em; }
.ds-tile .k { font-size: 11px; color: rgba(255,255,255,.5); letter-spacing: .05em; }
.ds-tile .v { font-size: 19px; font-weight: 600; margin-top: .15em; font-variant-numeric: tabular-nums; }

.ds-delta { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; margin-left: .4em; }
.ds-delta-good { color: var(--signal); }
.ds-delta-bad  { color: #ff7a7a; }

/* 近30天仪表横轨 */
.ds-gauge-rail { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); }
.ds-gauge { padding: .15em 1.2em; border-left: 1px solid var(--border); }
.ds-gauge:first-child { border-left: none; padding-left: 0; }
.ds-gauge .k { font-size: 12px; color: var(--muted); }
.ds-gauge .v { font-size: 22px; font-weight: 700; margin-top: .1em; color: var(--primary); font-variant-numeric: tabular-nums; }
.ds-gauge .v.pos { color: var(--signal); }
.ds-gauge .v.neg { color: var(--danger); }

/* 图表容器 */
.ds-chart-wrap { height: 280px; position: relative; }

/* 排行榜 */
.ds-rank { display: flex; flex-direction: column; }
.ds-rank-row {
  display: grid; grid-template-columns: 1.8em 1fr 38% auto; align-items: center; gap: .8em;
  padding: .55em 0; border-bottom: 1px solid var(--border);
}
.ds-rank-row:last-child { border-bottom: none; }
.ds-rank-num { font-size: 13px; font-weight: 700; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.ds-rank-row:first-child .ds-rank-num { color: var(--solar); }
.ds-rank-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-rank-track { background: var(--hover); border-radius: 999px; height: 8px; overflow: hidden; }
.ds-rank-fill { height: 100%; width: var(--pct, 0%); border-radius: 999px;
  background: linear-gradient(90deg, var(--solar), #F7C877); }
.ds-rank-val { font-size: 13px; font-weight: 600; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

.ds-empty { text-align: center; padding: 2.5em 1em; color: var(--muted); }
.ds-hint { font-size: 12px; color: var(--muted); }
.fx-input { padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; width: 180px; }
.fx-input:disabled { background: var(--hover); color: var(--muted); }
.fx-note { width: 240px; }
.ds-fx-warn { border: 1px solid var(--warning); background: #fff8ec; color: #9a5b00;
  border-radius: var(--radius); padding: .6em 1em; margin-bottom: 1em; font-size: 13px; }
.ds-loading { text-align: center; padding: 3em; color: var(--muted); }
.ds-error { text-align: center; padding: 3em; color: var(--danger); }

@media (max-width: 768px) {
  .ds-readout-num { font-size: 34px; }
  .ds-gauge { border-left: none; padding-left: 0; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- 产品表现宽表：横向滚动 + 冻结（标签行/首列）+ 列筛选行 ---------- */
.ds-table-scroll { overflow: auto; max-height: 62vh; }
.ds-pd-table { min-width: 100%; width: max-content; }
.ds-pd-table th { white-space: nowrap; }
.ds-pd-table td { white-space: nowrap; }
.ds-pd-table td.neg { color: var(--danger); }
/* 标签行（可点排序）冻结顶部 */
.ds-pd-table thead tr.pd-head th { position: sticky; top: 0; z-index: 3; }
.ds-pd-table thead tr.pd-head th.pd-sort { cursor: pointer; user-select: none; }
.ds-pd-table thead tr.pd-head th.pd-sort:hover { background: #eef1f6; }
/* 列筛选行：跟随滚动，不冻结顶部 */
.ds-pd-table thead tr.pd-filter th { position: static; top: auto; z-index: auto;
  background: var(--card-bg); padding: 3px 5px; }
.ds-pd-table thead tr.pd-filter input { width: 100%; box-sizing: border-box; font-size: 12px;
  padding: 3px 5px; border: 1px solid var(--border); border-radius: 4px; }
/* 首列冻结（标签行 + 数据行） */
.ds-pd-table thead tr.pd-head th:first-child { left: 0; z-index: 4; background: var(--hover); }
.ds-pd-table tbody td:first-child { position: sticky; left: 0; z-index: 1; background: var(--card-bg); }
.ds-pd-table tbody tr:hover td:first-child { background: var(--hover); }
