/* ============================================================
   设计系统 · “运营账本 / 终端” 视觉体系
   主题：亚马逊跨境运营驾驶舱 — 数字即仪表读数
   所有组件类以 ds- / pp- 前缀；新代码用类名，禁止 inline style
   ============================================================ */

:root {
  /* —— 品牌与墨色 —— */
  --ink: #16211d;          /* 近黑松绿：顶栏 / 标题 / 正文强调 */
  --ink-soft: #2b3a34;
  --brand: #0e5a54;        /* 深青：主按钮 / 品牌 / 排序高亮 / 焦点环 */
  --brand-deep: #0a423e;
  --brand-tint: #e4efec;   /* 品牌浅底 */
  /* —— 中性 —— */
  --canvas: #ebeeeb;       /* 冷纸画布（非奶油，避开AI默认） */
  --surface: #ffffff;
  --surface-2: #f5f7f5;
  --text: #1a2420;
  --muted: #5e6b66;
  --faint: #93a09a;
  --line: #dde3e0;
  --line-strong: #c9d1cd;
  /* —— 语义（ACOS 分档，独立于品牌色）—— */
  --ok: #1f7a4d;    --ok-bg: #e7f2ec;
  --warn: #a6791a;  --warn-bg: #f7efd9;
  --high: #bd611c;  --high-bg: #fbeadd;
  --loss: #b4322a;  --loss-bg: #fbe6e4;
  --noad: #8a938e;  --noad-bg: #eceeec;
  /* —— 系统级 —— */
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(22,33,29,.05), 0 12px 28px -18px rgba(22,33,29,.22);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
}

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

body {
  font-family: var(--font-sans);
  background: var(--canvas);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶栏（墨绿 chrome + 品牌青下边线） ---------- */
.ds-navbar {
  display: flex;
  align-items: center;
  background: var(--ink);
  color: #eef3f0;
  padding: 0 1.4em;
  height: 58px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 2px solid var(--brand);
}
.ds-navbar-brand {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .02em;
  margin-right: 2.2em;
  display: flex;
  align-items: center;
  gap: .55em;
  white-space: nowrap;
}
.ds-navbar-brand::before {
  content: "";
  width: 12px; height: 12px;
  background: var(--brand);
  box-shadow: 3px 3px 0 rgba(255,255,255,.18);
}
.ds-navbar-menu { display: flex; gap: .25em; flex: 1; }
.ds-navbar-menu a {
  color: rgba(238,243,240,.62);
  text-decoration: none;
  padding: .5em .95em;
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: color .15s, background .15s;
}
.ds-navbar-menu a:hover { color: #fff; background: rgba(255,255,255,.08); }
.ds-navbar-menu a.active { color: #fff; background: var(--brand); }
.ds-navbar-user { font-size: 13px; color: rgba(238,243,240,.85); display: flex; align-items: center; }

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

/* ---------- 卡片 ---------- */
.ds-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15em 1.4em;
  box-shadow: var(--shadow);
  margin-bottom: 1em;
}
.ds-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: .8em;
  padding-bottom: .55em;
  border-bottom: 1px solid var(--line);
  letter-spacing: .01em;
}

/* ---------- 按钮 ---------- */
.ds-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4em;
  padding: .55em 1.15em;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: background .15s, border-color .15s, opacity .15s;
}
.ds-btn-primary { background: var(--brand); color: #fff; }
.ds-btn-primary:hover { background: var(--brand-deep); }
.ds-btn-danger { background: var(--loss); color: #fff; }
.ds-btn-outline { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.ds-btn-outline:hover { border-color: var(--brand); color: var(--brand); }

/* ---------- 表格（“账本 tape”） ---------- */
.ds-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-variant-numeric: tabular-nums;
}
.ds-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  text-align: left;
  padding: .6em .8em;
  font-weight: 700;
  font-size: 11.5px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
.ds-table td {
  padding: .55em .8em;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--text);
}
.ds-table tr:hover td { background: var(--brand-tint); }
.ds-table td.num, .ds-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.ds-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.ds-table th.sortable:hover { color: var(--ink); }
.ds-table th.sorted { color: var(--brand); box-shadow: inset 0 -2px 0 var(--brand); }
.ds-table td.asin-cell { font-family: var(--font-mono); font-size: 12px; color: var(--ink); }
.ds-table td.title-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }

/* 签名①：行左侧 ACOS 严重度色脊（一眼扫出亏损行） */
.pp-row td:first-child { border-left: 3px solid transparent; }
.pp-band-loss    td:first-child { border-left-color: var(--loss); }
.pp-band-high    td:first-child { border-left-color: var(--high); }
.pp-band-watch   td:first-child { border-left-color: var(--warn); }
.pp-band-healthy td:first-child { border-left-color: var(--ok); }
.pp-band-noad    td:first-child { border-left-color: var(--line-strong); }

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

/* ---------- 输入框清空按钮 ---------- */
.inp-clear-wrap { position: relative; display: inline-flex; align-items: center; }
.inp-clear-btn {
  position: absolute; right: 8px;
  background: none; border: none; color: var(--faint);
  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: 999px; font-size: 12px; font-weight: 600; }
.ds-badge-success { background: var(--ok-bg); color: var(--ok); }
.ds-badge-warning { background: var(--warn-bg); color: var(--warn); }
.ds-badge-danger { background: var(--loss-bg); color: var(--loss); }

/* ---------- Toast ---------- */
.ds-toast {
  position: fixed; top: 74px; right: 1.5em;
  background: var(--ink); color: #fff;
  padding: .7em 1.3em; border-radius: var(--radius-sm);
  border-left: 3px solid var(--brand);
  z-index: 9999; font-size: 14px;
  box-shadow: var(--shadow);
  animation: dsSlideIn .28s ease;
}
@keyframes dsSlideIn { from { transform: translateX(10px); 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; }

/* ---------- 产品表现页 · KPI 仪表块 ---------- */
.pp-kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: .8em; margin-bottom: 1.1em; }
.pp-kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .85em 1em .9em;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column-reverse;   /* DOM: 值→标签；显示：标签在上 */
  gap: .3em;
  position: relative;
}
.pp-kpi-val {
  font-family: var(--font-mono);
  font-size: 23px;
  font-weight: 600;
  line-height: 1.05;
  color: var(--ink);
  letter-spacing: -.01em;
}
.pp-kpi-label {
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.pp-kpi.alert { border-left: 3px solid var(--loss); }
.pp-kpi.alert .pp-kpi-val { color: var(--loss); }

/* ---------- 筛选工具条 ---------- */
.pp-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .8em; }
.pp-field { display: flex; flex-direction: column; gap: .28em; }
.pp-field > span { font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.pp-field input, .pp-field select {
  padding: .48em .6em;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 13px; font-family: inherit;
  background: var(--surface); color: var(--text);
  min-width: 132px;
}
.pp-field input:focus, .pp-field select:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-tint);
}

/* ---------- 数据表容器 ---------- */
.pp-table-wrap {
  overflow: auto;
  max-height: calc(100vh - 340px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

/* ACOS chip */
.pp-chip {
  display: inline-block; padding: .12em .55em;
  border-radius: 999px; font-size: 12px; font-weight: 700;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
}
.pp-chip-healthy { background: var(--ok-bg); color: var(--ok); }
.pp-chip-watch { background: var(--warn-bg); color: var(--warn); }
.pp-chip-high { background: var(--high-bg); color: var(--high); }
.pp-chip-loss { background: var(--loss-bg); color: var(--loss); }
.pp-chip-noad { background: var(--noad-bg); color: var(--noad); }

.pp-state { text-align: center; color: var(--muted); padding: 3em 0; }

/* ---------- 登录闸门 ---------- */
.ds-hidden { display: none !important; }
.ds-checking {
  min-height: 82vh; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-family: var(--font-mono); font-size: 13px; letter-spacing: .04em;
}

/* 签名③：登录页“坐标纸”网格 + 品牌标记（张力集中于此） */
.ds-login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 2em;
  background:
    linear-gradient(var(--canvas), var(--canvas)),
    linear-gradient(rgba(14,90,84,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(14,90,84,.05) 1px, transparent 1px);
  background-size: 100% 100%, 26px 26px, 26px 26px;
}
.ds-login-card {
  width: 372px; max-width: 92%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--brand);
  border-radius: 4px 4px var(--radius) var(--radius);
  box-shadow: 0 24px 60px -28px rgba(22,33,29,.4);
  padding: 2.4em 2.1em 2.1em;
  text-align: center;
}
.ds-login-mark {
  display: inline-flex; align-items: center; gap: .5em;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--brand); margin-bottom: 1.3em;
}
.ds-login-mark::before { content: ""; width: 11px; height: 11px; background: var(--brand); box-shadow: 3px 3px 0 var(--brand-tint); }
.ds-login-title { margin: 0 0 .3em; font-size: 21px; font-weight: 700; color: var(--ink); }
.ds-login-sub { color: var(--muted); margin: 0 0 1.9em; font-size: 13px; }
.ds-login-btn {
  width: 100%; padding: .8em 0; font-size: 15px; font-family: inherit;
  cursor: pointer; border: none; border-radius: var(--radius-sm);
  background: var(--brand); color: #fff;
  display: inline-flex; justify-content: center; align-items: center; gap: .5em;
  transition: background .15s;
}
.ds-login-btn:hover { background: var(--brand-deep); }
.ds-login-btn:disabled { opacity: .6; cursor: default; }
.ds-login-hint { color: var(--loss); font-size: 12px; margin: 1em 0 0; min-height: 1.2em; }
.ds-logout-btn {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.4);
  color: #fff; padding: .34em 1em; border-radius: var(--radius-sm); cursor: pointer;
  font-family: inherit; font-size: 13px;
}
.ds-logout-btn:hover { background: rgba(255,255,255,.2); }
.ds-user-name { margin-right: .9em; font-weight: 600; }

@media (max-width: 900px) {
  .pp-kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .ds-toast { animation: none; }
}
