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

:root {
  --primary: #2563eb;        /* 科技蓝 */
  --primary-2: #3b82f6;
  --primary-ink: #1e3a8a;
  --accent: #06b6d4;         /* 未来青 */
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #eef2fb;
  --card-bg: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e3e9f4;
  --hover: #f1f5fb;
  --radius: 10px;
  --shadow: 0 4px 16px rgba(37,99,235,.08);
  --shadow-lg: 0 10px 30px rgba(37,99,235,.16);
  --glow: 0 0 0 3px rgba(37,99,235,.16);
  --grad: linear-gradient(135deg, #3b82f6 0%, #2563eb 60%, #1d4ed8 100%);
  --grad-cyan: linear-gradient(135deg, #22d3ee 0%, #2563eb 100%);
}

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

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  background:
    radial-gradient(1200px 520px at 82% -12%, rgba(37,99,235,.12), transparent 60%),
    radial-gradient(900px 420px at -5% 0%, rgba(6,182,212,.10), transparent 55%),
    var(--bg);
  background-attachment: fixed;
}

/* ---------- 导航栏 ---------- */
.ds-navbar {
  display: flex;
  align-items: center;
  background: linear-gradient(90deg, #0b1b3f 0%, #16307a 52%, #1d4ed8 100%);
  color: #fff;
  padding: 0 1.5em;
  height: 58px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(34,211,238,.4), 0 8px 26px rgba(11,27,63,.30);
}
.ds-navbar-brand {
  font-size: 18px; font-weight: 700; margin-right: 2em;
  letter-spacing: .5px;
  display: inline-flex; align-items: center; gap: .55em;
}
.ds-navbar-brand::before {
  content: ""; width: 11px; height: 11px; border-radius: 3px;
  background: linear-gradient(135deg, #22d3ee, #3b82f6);
  box-shadow: 0 0 12px rgba(34,211,238,.95);
}
.ds-navbar-menu { display: flex; gap: .35em; flex: 1; }
.ds-navbar-menu a {
  color: rgba(255,255,255,0.72);
  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.12);
  box-shadow: inset 0 0 0 1px rgba(34,211,238,.45);
}
.ds-navbar-user { font-size: 13px; color: rgba(255,255,255,0.82); }

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

/* ---------- 卡片 ---------- */
.ds-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2em 1.5em;
  box-shadow: var(--shadow);
  margin-bottom: 1em;
  transition: box-shadow .2s ease, transform .2s ease;
}
.ds-stat:hover, .ds-card:hover { box-shadow: var(--shadow-lg); }
.ds-card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: .8em;
  padding-bottom: .5em;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.ds-card-title::after {
  content: ""; position: absolute; left: 0; bottom: -1px;
  width: 44px; height: 2px; border-radius: 2px;
  background: var(--grad-cyan);
}

/* ---------- 按钮 ---------- */
.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;
  font-weight: 500;
  transition: all .2s;
}
.ds-btn-primary { background: var(--grad); color: #fff; box-shadow: 0 2px 10px rgba(37,99,235,.35); }
.ds-btn-primary:hover { filter: brightness(1.07); box-shadow: 0 5px 18px rgba(37,99,235,.45); transform: translateY(-1px); }
.ds-btn-danger { background: var(--danger); color: #fff; }
.ds-btn-outline { background: rgba(255,255,255,.65); border: 1px solid var(--border); color: var(--text); }
.ds-btn-outline:hover { border-color: var(--primary); color: var(--primary); box-shadow: var(--shadow); }
.ds-btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; transform: none; }

/* ---------- 表格 ---------- */
.ds-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.ds-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #e9f0ff;
  color: var(--primary-ink);
  text-align: left;
  padding: .6em .8em;
  font-weight: 600;
  font-size: 13px;
  border-bottom: 2px solid #d5e1fb;
  white-space: nowrap;
}
.ds-table td {
  padding: .55em .8em;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.ds-table tbody 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; }
.mb-sm { margin-bottom: .6em; }
.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; }

/* ---------- 表单控件 ---------- */
.ds-select, .ds-input {
  padding: .45em .7em;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text);
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.ds-select:focus, .ds-input:focus,
.ds-table-wrap select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--glow);
}
.ds-field { display: inline-flex; flex-direction: column; gap: .3em; }
.ds-field-label { font-size: 12px; color: var(--muted); }
.ds-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1em;
  margin-bottom: 1em;
}

/* ---------- 表格滚动容器（配合 sticky 表头冻结首行） ---------- */
.ds-table-wrap {
  max-height: 62vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.ds-table td.num, .ds-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- 统计卡 ---------- */
.ds-stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1em; margin-bottom: 1.2em; }
.ds-stat {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9em 1.1em .9em 1.3em;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: box-shadow .2s ease, transform .2s ease;
}
.ds-stat::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--grad-cyan);
}
.ds-stat:hover { transform: translateY(-2px); }
.ds-stat-label { font-size: 12px; color: var(--muted); margin-bottom: .3em; }
.ds-stat-value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .3px; }

.ds-stat-value.primary { color: var(--primary); }
.ds-stat-value.ok { color: var(--success); }
.ds-stat-value.warn { color: #e65100; }
.ds-stat-value.danger { color: var(--danger); }
.ds-stat-sub { font-size: 12px; color: var(--muted); margin-top: .3em; }

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

/* ---------- 商品缩略图 ---------- */
.ds-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); background: var(--hover); }
.ds-title-cell { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 概览键值列表 ---------- */
.ds-kv { display: flex; justify-content: space-between; padding: .55em 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.ds-kv:last-child { border-bottom: none; }
.ds-kv-val { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- 状态提示 ---------- */
.ds-state { text-align: center; color: var(--muted); padding: 3em 0; }
.ds-note { font-size: 12px; color: var(--muted); margin-top: .6em; }
@media (max-width: 720px) {
  .ds-stat-row { grid-template-columns: repeat(2, 1fr); }
}
