/* ============================================================
   设计系统 · Instrument Console
   跨境运营盯盘控制台 —— 冷瓷画布 / 石板墨结构 / 琥珀信号
   所有组件类名以 ds- 为前缀；CSS 变量名保持稳定（JS 内联样式有引用）。
   ============================================================ */

:root {
  /* —— 结构色 —— */
  --ink:      #16232A;   /* 近黑石板：导航 / 强调文字 / 表头 */
  --primary:  #16232A;   /* 兼容旧名：JS 用它作标题/主按钮底色 */
  --text:     #24343C;
  --muted:    #6C7B84;
  --faint:    #97A4AB;

  /* —— 表面 —— */
  --bg:       #E7ECEE;   /* 冷瓷灰画布 */
  --card-bg:  #FFFFFF;
  --sunken:   #F1F5F6;   /* 凹陷/斑马纹 */
  --hover:    #EEF3F4;
  --border:   #D9E0E3;
  --border-strong: #C4CDD1;

  /* —— 信号色 —— */
  --accent:      #C06A16;   /* 焦糖琥珀：品牌信号，全局唯一的高饱和 */
  --accent-ink:  #A85A0F;   /* 琥珀按下/hover */
  --accent-soft: #FaF0E4;   /* 琥珀浅底 */
  --signal:      #0E7C7B;   /* 青绿：链接/次强调 */
  --signal-soft: #E4F1F0;

  /* —— 语义色 —— */
  --success: #1F7A4D;
  --success-soft: #E6F3EC;
  --warning: #B0761A;
  --warning-soft: #FBF1DE;
  --danger:  #C23B3B;
  --danger-soft: #FBEBEA;

  --radius:    10px;
  --radius-sm: 7px;
  --shadow:    0 1px 2px rgba(20,35,42,.06), 0 2px 8px rgba(20,35,42,.05);
  --shadow-lg: 0 4px 16px rgba(20,35,42,.10);
  --ring:      0 0 0 3px rgba(192,106,22,.28);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;   /* 数字等宽，天然对齐 */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(192,106,22,.18); }

a { color: var(--signal); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 4px; }

/* ---------- 导航栏（控制台头） ---------- */
.ds-navbar {
  display: flex;
  align-items: center;
  gap: 1.5em;
  background: var(--ink);
  color: #fff;
  padding: 0 1.5em;
  height: 58px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(255,255,255,.04), 0 6px 18px rgba(20,35,42,.16);
}
.ds-navbar-brand {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .01em;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: .55em;
}
/* 品牌前的琥珀标记 —— 全局签名 */
.ds-navbar-brand::before {
  content: "";
  width: 9px; height: 20px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent), var(--accent-ink));
  box-shadow: 0 0 10px rgba(192,106,22,.55);
}
.ds-navbar-menu { display: flex; gap: .25em; flex: 1; flex-wrap: wrap; }
.ds-navbar-menu a {
  position: relative;
  color: rgba(255,255,255,.66);
  padding: .55em .9em;
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: color .18s, background .18s;
}
.ds-navbar-menu a:hover { color: #fff; background: rgba(255,255,255,.08); text-decoration: none; }
.ds-navbar-menu a.active { color: #fff; background: rgba(255,255,255,.06); }
.ds-navbar-menu a.active::after {
  content: "";
  position: absolute; left: .9em; right: .9em; bottom: -1px; height: 2px;
  background: var(--accent);
  border-radius: 2px;
}
.ds-navbar-user { font-size: 13px; color: rgba(255,255,255,.85); display: flex; align-items: center; }

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

/* ---------- 卡片 ---------- */
.ds-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25em 1.5em;
  box-shadow: var(--shadow);
  margin-bottom: 1em;
}
.ds-card-title {
  display: flex;
  align-items: center;
  gap: .55em;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .01em;
  color: var(--ink);
  margin-bottom: .9em;
  padding-bottom: .6em;
  border-bottom: 1px solid var(--border);
}
/* 标题前琥珀短竖条 —— 全局签名 */
.ds-card-title::before {
  content: "";
  width: 3px; align-self: stretch; min-height: 15px;
  border-radius: 2px;
  background: var(--accent);
}

/* KPI 卡里的大数字（嵌套 ds-card）：更紧的字距，突出前置 */
.ds-card .ds-card {
  box-shadow: none;
  border-color: var(--border);
  background: linear-gradient(180deg, #fff, #fcfdfd);
}

/* 小标签 / eyebrow */
.ds-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--faint);
}

/* ---------- 按钮 ---------- */
.ds-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45em;
  padding: .5em 1.15em;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.4;
  /* 裸 .ds-btn 默认即品牌琥珀 CTA */
  background: var(--accent);
  color: #fff;
  transition: background .18s, box-shadow .18s, transform .05s, border-color .18s, color .18s;
}
.ds-btn:hover { background: var(--accent-ink); }
.ds-btn:active { transform: translateY(1px); }
.ds-btn:disabled { opacity: .5; cursor: not-allowed; }

.ds-btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.ds-btn-primary:hover { background: #22333d; }

.ds-btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.ds-btn-danger:hover { background: #a83030; }

.ds-btn-outline { background: #fff; border-color: var(--border-strong); color: var(--text); }
.ds-btn-outline:hover { background: var(--hover); border-color: var(--muted); color: var(--ink); }

/* ---------- 表单控件 ---------- */
input, select {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: .48em .7em;
  transition: border-color .18s, box-shadow .18s;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
input::placeholder { color: var(--faint); }
label { color: var(--muted); font-size: 13px; }

/* ---------- 表格 ---------- */
.ds-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-variant-numeric: tabular-nums;
}
.ds-table th {
  position: sticky;
  top: 58px;                 /* 贴在控制台头下方 */
  z-index: 2;
  background: var(--ink);
  color: rgba(255,255,255,.9);
  text-align: left;
  padding: .62em .8em;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .03em;
  white-space: nowrap;
  border-bottom: none;
}
.ds-table th:first-child { border-top-left-radius: var(--radius-sm); }
.ds-table th:last-child  { border-top-right-radius: var(--radius-sm); }
.ds-table td {
  padding: .58em .8em;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
}
.ds-table tbody tr:nth-child(even) { background: var(--sunken); }
.ds-table tbody tr:hover { background: var(--signal-soft); }
.ds-table tbody tr:last-child td { border-bottom: none; }

/* ---------- 列拖拽把手 ---------- */
.col-resize-handle {
  position: absolute; right: 0; top: 0;
  width: 5px; height: 100%;
  cursor: col-resize;
  background: transparent;
  transition: background .15s;
}
.col-resize-handle:hover { background: rgba(192,106,22,.35); }

/* ---------- 输入框清空按钮 ---------- */
.inp-clear-wrap { position: relative; display: inline-flex; align-items: center; }
.inp-clear-wrap input { padding-right: 26px; }
.inp-clear-btn {
  position: absolute; right: 7px;
  background: none; border: none;
  color: var(--faint); cursor: pointer;
  font-size: 16px; line-height: 1;
  display: none;
}
.inp-clear-btn:hover { color: var(--ink); }
.inp-clear-wrap input:not(:placeholder-shown) + .inp-clear-btn { display: block; }

/* ---------- 徽章 ---------- */
.ds-badge {
  display: inline-flex; align-items: center;
  padding: .18em .6em;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}
.ds-badge-success { background: var(--success-soft); color: var(--success); border-color: rgba(31,122,77,.2); }
.ds-badge-warning { background: var(--warning-soft); color: #8a5a10; border-color: rgba(176,118,26,.25); }
.ds-badge-danger  { background: var(--danger-soft);  color: var(--danger);  border-color: rgba(194,59,59,.2); }

/* ---------- 提示 Toast ---------- */
.ds-toast {
  position: fixed;
  top: 74px; right: 1.5em;
  background: var(--ink);
  color: #fff;
  padding: .8em 1.3em;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  font-size: 14px;
  border-left: 3px solid var(--accent);
  animation: slideIn .28s cubic-bezier(.2,.7,.3,1);
}
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } }

/* 卡片入场（克制、尊重 reduced-motion） */
.ds-main > .ds-card { animation: rise .32s cubic-bezier(.2,.7,.3,1) both; }
.ds-main > .ds-card:nth-child(2) { animation-delay: .04s; }
.ds-main > .ds-card:nth-child(3) { animation-delay: .08s; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ---------- 布局工具类 ---------- */
.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; }

/* ---------- 响应式（质量底线：到手机） ---------- */
@media (max-width: 960px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .ds-navbar { height: auto; padding: .6em 1em; flex-wrap: wrap; gap: .6em; }
  .ds-table th { top: 0; }
  .ds-main { padding: 1.1em 1em 2.5em; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
