/* ============================================================
   设计系统 - 所有组件类名以 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); }

/* ---------- 货件分仓 ---------- */
.inb-banner {
  background: #fff7d6;
  color: #8a5a00;
  border: 1px solid #f4d36b;
  border-radius: var(--radius);
  padding: .7em 1em;
  margin-bottom: 1em;
}
.inb-form-grid {
  display: grid;
  grid-template-columns: 1fr 110px 44px;
  gap: .6em;
  align-items: center;
  margin-bottom: .6em;
}
.inb-form-grid input,
.inb-weight input,
.inb-marketplace {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5em .7em;
  font-size: 14px;
}
.inb-recommended { background: #f1f8f2; }
.inb-detail {
  background: var(--hover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .8em;
  font-size: 12px;
}
.inb-weight {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr)) auto;
  gap: .8em;
  align-items: end;
}
.inb-muted { color: var(--muted); font-size: 12px; }
.inb-actions { display: flex; gap: .5em; align-items: center; flex-wrap: wrap; }

@media (max-width: 760px) {
  .inb-form-grid { grid-template-columns: 1fr; }
  .inb-weight { grid-template-columns: 1fr; }
}

/* ---------- 提示 ---------- */
.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; }

/* ---------- 登录 / 用户态（从内存快照恢复） ---------- */
.ds-login { max-width: 360px; margin: 12vh auto; text-align: center; }
.ds-login h2 { font-size: 20px; margin-bottom: 1.2em; color: var(--text); }
.ds-login .ds-btn { width: 100%; justify-content: center; padding: .7em 1.2em; }
.ds-qr { width: 260px; height: 260px; margin: .5em auto 0; display: flex; align-items: center; justify-content: center; }
.ds-qr iframe { border: none; }
.ds-qr-tip { margin-top: 1em; font-size: 13px; color: var(--muted); }
.ds-user { display: flex; align-items: center; gap: .6em; }
.ds-user-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.ds-user .ds-btn { padding: .3em .9em; font-size: 12px; }

/* ---------- KPI 统计块 ---------- */
.ds-stat { background: var(--card-bg); border-radius: var(--radius); padding: 1em 1.2em; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.ds-stat-label { font-size: 13px; color: var(--muted); margin-bottom: .4em; }
.ds-stat-value { font-size: 22px; font-weight: 700; color: var(--text); }

/* ---------- 产品表现 KPI 卡 ---------- */
.pp-kpi { background: var(--card-bg); border-radius: var(--radius); padding: 1em 1.2em; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.pp-kpi-label { font-size: 13px; color: var(--muted); margin-bottom: .4em; }
.pp-kpi-val { font-size: 22px; font-weight: 700; color: var(--text); }
.pp-sortable { cursor: pointer; user-select: none; }
.pp-sortable:hover { color: var(--primary); }

/* ========== 机器人通知 Demo (nd-*) ========== */
.nd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1em;
}
.nd-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border-left: 4px solid var(--muted);
  padding: 1.1em 1.3em;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
}
.nd-head {
  display: flex;
  align-items: center;
  gap: .5em;
  margin-bottom: .5em;
}
.nd-icon { font-size: 1.4em; }
.nd-title { font-size: 1.05em; font-weight: 600; color: var(--text); }
.nd-desc {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  margin: 0 0 .8em;
  flex: 1;
}
.nd-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .4em;
  margin-bottom: 1em;
}
.nd-tag {
  font-size: 12px;
  color: var(--primary);
  background: var(--hover);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .15em .7em;
}
.nd-send { align-self: flex-start; }

/* 各场景左侧强调色（对应飞书卡片配色） */
.nd-accent-green   { border-left-color: #2E7D32; }
.nd-accent-red     { border-left-color: #c0392b; }
.nd-accent-orange  { border-left-color: #FF9800; }
.nd-accent-turquoise { border-left-color: #17a2b8; }
.nd-accent-carmine { border-left-color: #d6336c; }

/* ========== 识别图片 (voc-*) ========== */
.voc-uploader {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--hover);
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  overflow: hidden;
}
.voc-uploader:hover, .voc-drag { border-color: var(--primary); background: #eef1f7; }
.voc-hint { text-align: center; color: var(--muted); padding: 1.5em; }
.voc-hint-ic { font-size: 2.4em; margin-bottom: .3em; }
.voc-hint-sub { font-size: 12px; margin-top: .3em; color: #aaa; }
.voc-preview { max-width: 100%; max-height: 420px; display: block; }
.voc-result {
  width: 100%;
  min-height: 220px;
  margin-top: .8em;
  padding: .8em 1em;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  resize: vertical;
  box-sizing: border-box;
  white-space: pre-wrap;
}
