/* ============================================================
 * StarDream toys · 跟单系统
 * 视觉风格：美国政府部门 / USWDS 风
 * - 深海军蓝 + 红 + 白 + 浅灰
 * - 直角（border-radius: 0），不用阴影
 * - 顶部官方风格 banner
 * - 强对比、信息密集、严肃稳重
 * ============================================================ */
:root {
  /* USWDS 调色板 */
  --primary:        #005ea2;     /* base blue */
  --primary-dark:   #162e51;     /* dark navy（navbar） */
  --primary-darker: #0b2042;
  --primary-soft:   #d9e8f6;     /* light blue */
  --primary-text:   #005ea2;

  --accent-red:     #b50909;
  --accent-gold:    #ffbe2e;

  --bg:             #ffffff;
  --bg-alt:         #f0f0f0;     /* gray-cool-5 */
  --bg-stripe:      #f0f0f0;
  --card:           #ffffff;
  --card-hover:     #f8f9fa;
  --border:         #a9aeb1;     /* gray-cool-30 主边框 */
  --border-light:   #dfe1e2;
  --border-strong:  #565c65;

  --text:           #1b1b1b;
  --text-soft:      #3d4551;
  --muted:          #565c65;

  --success:        #00a91c;
  --warning:        #e5a000;
  --danger:         #b50909;
  --info:           #00bde3;

  /* 字体 */
  --font-sans:      "Public Sans", "Source Sans 3", "Source Sans Pro", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono:      "DejaVu Sans Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* App 壳布局：body 严格 100vh 不滚动；内容区在 main 内部滚动（且滚动条隐藏）
   好处：1) navbar 永远不跳位 2) 短页面（概览/登录）完全没滚动条 3) 长页面用滚轮在 main 内滚 */
html, body { height: 100%; overflow: hidden; scrollbar-width: none; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column;
}
.usa-banner, .navbar { flex-shrink: 0; }
main.container {
  flex: 1; overflow-y: auto;
  scrollbar-width: none;
}
main.container::-webkit-scrollbar { width: 0; height: 0; display: none; }
a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--primary-darker); text-decoration: underline; }
/* 内部 CRM 不区分 visited 颜色 —— 否则 navbar/按钮等深色背景上的链接会变成不可见的紫黑 */
a.brand, a.btn, .nav-links a, a[class*="badge"], .pagination a, .logout {
  text-decoration: none;
}
.brand, .brand:visited, .brand:hover { color: #fff; }
.nav-links a, .nav-links a:visited { color: #fff; }
.btn, .btn:visited { color: var(--text); }
.btn-primary, .btn-primary:visited, .btn-danger, .btn-danger:visited { color: #fff; }
::selection { background: var(--primary); color: #fff; }

/* 主页面（html/body）滚动条彻底不显示 */
html::-webkit-scrollbar,
body::-webkit-scrollbar { width: 0; height: 0; display: none; }
/* 其它内部滚动区（表格横向、聊天历史等）保留可见浅灰滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-alt); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* 图标 */
.icon {
  display: inline-block; width: 1em; height: 1em;
  vertical-align: -0.15em;
  stroke-width: 2;
  stroke-linecap: square; stroke-linejoin: miter;
  fill: none; stroke: currentColor; flex-shrink: 0;
}
.icon-lg { width: 1.25em; height: 1.25em; vertical-align: -0.2em; }
.icon-xl { width: 1.5em;  height: 1.5em;  vertical-align: -0.25em; }
.icon-filled { fill: currentColor; stroke: none; }
.gpt-spinner { animation: gpt-spin 1.2s linear infinite; transform-origin: center; }
@keyframes gpt-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ─────── 顶部 Official banner（USWDS 标志性元素） ─────── */
.usa-banner {
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border-light);
  font-size: 12px;
  color: var(--text);
}
.usa-banner-inner {
  max-width: 1400px; margin: 0 auto; padding: 6px 32px;
  display: flex; align-items: center; gap: 12px;
}
.usa-banner-flag {
  width: 16px; height: 11px;
  background:
    linear-gradient(to bottom, #b22234 0, #b22234 1.57px, #fff 1.57px, #fff 3.14px,
      #b22234 3.14px, #b22234 4.71px, #fff 4.71px, #fff 6.28px,
      #b22234 6.28px, #b22234 7.85px, #fff 7.85px, #fff 9.42px,
      #b22234 9.42px, #b22234 11px);
  position: relative;
}
.usa-banner-flag::before {
  content: ""; position: absolute; top: 0; left: 0;
  width: 7px; height: 6px; background: #3c3b6e;
}
.usa-banner-text { color: var(--text-soft); }
.usa-banner-text strong { color: var(--text); font-weight: 700; }

/* ---- Navbar ---- */
.navbar {
  background: var(--primary-dark);
  border-bottom: 4px solid var(--primary);
  position: sticky; top: 0; z-index: 50;
  /* 锁全视口宽，配合下面已隐藏的 scrollbar，长短页面切换 navbar 不跳位 */
  width: 100%;
}
.navbar-inner {
  max-width: 1400px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; gap: 20px; min-height: 72px;
}
.brand {
  font-weight: 700; font-size: 18px; color: #fff;
  display: inline-flex; align-items: center; gap: 10px;
  letter-spacing: 0.02em;
  white-space: nowrap; flex-shrink: 0;
}
.brand:hover { color: #fff; opacity: 0.9; }
.nav-links {
  list-style: none; margin: 0; padding: 0;
  display: flex; gap: 14px; flex: 1; justify-content: center;
  align-items: stretch;
  align-self: stretch;
  min-width: 0;
}
.nav-links li { display: flex; }
.nav-links a {
  color: #fff;
  padding: 0 14px; display: inline-flex; align-items: center;
  font-size: 14px; font-weight: 700;
  letter-spacing: 0.02em;
  border-bottom: 4px solid transparent;
  margin-bottom: -4px;
  white-space: nowrap;
  transition: background 0.12s;
}
.nav-links a:hover { background: rgba(255,255,255,0.15); color: #fff; }
.nav-links a.active { background: rgba(255,255,255,0.1); border-bottom-color: var(--accent-gold); color: #fff; }
.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  margin-left: 6px; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 9px;
  background: var(--accent-red); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 1;
}
.nav-right {
  display: flex; align-items: center; gap: 12px;
  font-size: 13px; color: #fff;
  flex-shrink: 0; white-space: nowrap;
}
.user-label, .user-label:visited { color: #d6d7d9; text-decoration: none; white-space: nowrap; }
.user-label:hover { color: #fff; text-decoration: underline; text-underline-offset: 3px; }
.store-switch select {
  padding: 0 8px; border-radius: 0; border: 1px solid #fff;
  background: var(--primary-dark); color: #fff; font-size: 13px; height: 32px;
}
.store-label {
  padding: 4px 10px; background: var(--primary); color: #fff;
  border-radius: 0; font-weight: 600;
  white-space: nowrap;
}
.logout-form { display: inline; margin: 0; padding: 0; }
.logout {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: #d6d7d9; font: inherit; font-size: 13px;
  text-decoration: underline; text-underline-offset: 2px;
  white-space: nowrap;
}
.logout:hover { color: #fff; }

/* ---- Container ---- */
.container { max-width: 1400px; margin: 0 auto; padding: 12px 32px 16px; width: 100%; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
  position: relative;
}
.page-header h1 {
  font-size: 20px; margin: 0; color: var(--text);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-weight: 700;
  flex: 1;
  /* 跟 navbar 主菜单一样居中 */
  text-align: center;
}
.page-header .actions {
  display: flex; gap: 8px;
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
}

/* ---- Card ---- */
.card {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-top: 3px solid var(--primary);
  border-radius: 0;
  padding: 12px 16px;
  margin-bottom: 10px;
}
.card h2 {
  font-size: 14px; margin: 0 0 8px 0;
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 700;
}
.card.center { text-align: center; padding: 32px; }
.muted { color: var(--muted); }

/* ---- Stats Grid ---- */
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0; margin-bottom: 10px;
  border: 1px solid var(--border-light);
}
.stat {
  background: #fff;
  border-right: 1px solid var(--border-light);
  border-top: 3px solid var(--primary);
  padding: 10px 14px;
}
.stat:last-child { border-right: none; }
.stat.primary  { border-top-color: var(--primary); }
.stat.success  { border-top-color: var(--success); }
.stat.warning  { border-top-color: var(--warning); }
.stat.danger   { border-top-color: var(--danger); }
.stat .label {
  color: var(--text-soft); font-size: 12px;
  font-weight: 600;
}
.stat .value {
  font-size: 22px; font-weight: 700; margin-top: 2px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

/* ---- Table ---- */
.table-wrap { background: #fff; border: 1px solid var(--border-light); border-radius: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 12px 16px; text-align: left;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
  white-space: nowrap;   /* 默认不换行，整表可横向滚 */
}
/* 主题 / 备注等长文本列允许换行（加 class="td-wrap"） */
.table-wrap td.td-wrap, .table-wrap td.subject { white-space: normal; }
th {
  background: var(--bg-alt);
  font-weight: 700; font-size: 13px; color: var(--text);
  border-bottom: 2px solid var(--border-strong);
}
tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) td { background: #fafafa; }   /* 斑马纹 */
tr:hover td { background: var(--primary-soft) !important; }
td { font-variant-numeric: tabular-nums; }
.col-actions { width: 140px; white-space: nowrap; text-align: right; }
.empty { padding: 48px; text-align: center; color: var(--muted); background: var(--bg-alt); }

/* ---- Form ---- */
form label {
  display: block; margin-bottom: 16px; font-weight: 700;
  font-size: 14px; color: var(--text);
}
form label span.optional { color: var(--muted); font-weight: 400; font-size: 13px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], select {
  width: 100%; margin-top: 6px;
  height: 40px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: 0;
  font-size: 16px; font-family: inherit; background: #fff;
  color: var(--text);
}
textarea {
  width: 100%; margin-top: 6px; padding: 10px 12px;
  border: 1px solid var(--border-strong); border-radius: 0;
  font-size: 16px; font-family: inherit; background: #fff;
  color: var(--text); line-height: 1.5;
  min-height: 96px; resize: vertical;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);   /* 不向外扩，避免和邻近按钮错位 */
}
input::placeholder, textarea::placeholder { color: #757575; }

.form-row   { display: grid; grid-template-columns: 1fr 1fr;     gap: 24px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; }

/* ---- Button ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 20px;
  border-radius: 0;
  border: 0;
  background: var(--bg-alt); color: var(--text);
  font-size: 15px; font-weight: 700;
  cursor: pointer; text-decoration: none; font-family: inherit;
  line-height: 1;
  white-space: nowrap;
  transition: background 0.1s;
}
.btn:hover { background: #c9c9c9; color: var(--text); }
.btn:focus { outline: none; box-shadow: inset 0 0 0 2px var(--primary); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-darker); color: #fff; }
.btn-danger { background: var(--accent-red); color: #fff; }
.btn-danger:hover { background: #8b1313; color: #fff; }
.btn-sm { height: 30px; padding: 0 14px; font-size: 13px; }
.btn-block { display: flex; width: 100%; height: 48px; margin-top: 16px; }

/* ---- Flash ---- */
.flash {
  padding: 14px 18px; margin-bottom: 24px; border-radius: 0;
  font-size: 15px; border-left: 8px solid;
  background: #fff; border-top: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light); border-bottom: 1px solid var(--border-light);
}
.flash-success { border-left-color: var(--success); }
.flash-error   { border-left-color: var(--danger); }
.flash-info    { border-left-color: var(--info); }

/* ---- Status badges ---- */
.badge {
  display: inline-block;
  padding: 2px 8px; border-radius: 0;
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.04em;
  border: 1px solid;
  white-space: nowrap;       /* 徽章文字永不换行 */
}
/* 询盘 */
.badge-new          { background: #fff; color: var(--primary);     border-color: var(--primary); }
.badge-quoted       { background: #fff; color: var(--warning);     border-color: var(--warning); }
.badge-negotiating  { background: #fff; color: #6d28d9;            border-color: #6d28d9; }
.badge-won          { background: var(--success); color: #fff;     border-color: var(--success); }
.badge-lost         { background: var(--danger);  color: #fff;     border-color: var(--danger); }
.badge-archived     { background: #fff; color: var(--muted);       border-color: var(--muted); }
/* 订单 */
.badge-pending          { background: #fff; color: var(--muted);     border-color: var(--muted); }
.badge-in_production    { background: #fff; color: var(--warning);   border-color: var(--warning); }
.badge-ready_to_ship    { background: #fff; color: #00a6a6;          border-color: #00a6a6; }
.badge-shipped          { background: #fff; color: var(--primary);   border-color: var(--primary); }
.badge-delivered        { background: #fff; color: #6d28d9;          border-color: #6d28d9; }
.badge-completed        { background: var(--success); color: #fff;   border-color: var(--success); }
.badge-cancelled        { background: var(--danger);  color: #fff;   border-color: var(--danger); }
/* 付款 */
.badge-unpaid       { background: var(--danger); color: #fff;        border-color: var(--danger); }
.badge-deposit_paid { background: #fff; color: var(--warning);       border-color: var(--warning); }
.badge-fully_paid   { background: var(--success); color: #fff;       border-color: var(--success); }
.badge-refunded     { background: #fff; color: var(--muted);         border-color: var(--muted); }
/* 审计日志操作 */
.badge-login    { background: #fff; color: var(--primary);    border-color: var(--primary); }
.badge-logout   { background: #fff; color: var(--muted);      border-color: var(--muted); }
.badge-create   { background: #fff; color: var(--success);    border-color: var(--success); }
.badge-update   { background: #fff; color: var(--warning);    border-color: var(--warning); }
.badge-delete   { background: var(--danger); color: #fff;     border-color: var(--danger); }

/* 样品 */
.badge-free         { background: #fff; color: var(--muted);         border-color: var(--muted); }
.badge-sample_paid  { background: var(--success); color: #fff;       border-color: var(--success); }
.badge-making       { background: #fff; color: var(--warning);       border-color: var(--warning); }
.badge-received     { background: #fff; color: #6d28d9;              border-color: #6d28d9; }
/* 供应商 */
.badge-supplier-active     { background: var(--success); color: #fff; border-color: var(--success); }
.badge-supplier-evaluating { background: #fff; color: var(--warning); border-color: var(--warning); }
.badge-supplier-paused     { background: #fff; color: var(--muted);   border-color: var(--muted); }
.badge-supplier-blacklist  { background: var(--danger); color: #fff;  border-color: var(--danger); }

/* 供应商评级星星 */
.supplier-rating { display: inline-flex; gap: 1px; font-size: 14px; line-height: 1; }
.supplier-rating .star-on  { color: #f0a500; }
.supplier-rating .star-off { color: #d6d7d9; }

/* ---- Login ---- */
/* 不用 100vh 撑满（会和 banner+container padding 叠加溢出），用上下 padding 自然撑开 */
.login-wrap {
  display: flex; align-items: center; justify-content: center;
  padding: 64px 16px;
}
.login-card {
  max-width: 400px; width: 100%;
  border: 1px solid var(--border-light);
  border-top: 8px solid var(--primary);
  padding: 40px 36px;
}
.login-title {
  text-align: center; margin: 0 0 8px;
  font-size: 28px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.center { text-align: center; }

/* ---- Filters ---- */
.filters {
  display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; align-items: center;
  padding: 16px;
  background: var(--bg-alt);
  border: 1px solid var(--border-light);
}
.filters input, .filters select { width: auto; margin: 0; min-width: 160px; }
.filters input[type=text] { min-width: 320px; }      /* 搜索框文字更长，单独加宽 */

/* ---- Dashboard 双列 ---- */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dashboard-grid .card { min-width: 0; }
.dashboard-grid .card td, .dashboard-grid .card th { padding: 6px 10px; font-size: 12.5px; }
.dashboard-grid .table-scroll { overflow-x: auto; margin: 0 -16px -16px; padding: 0 16px 16px; }
.dashboard-grid table { table-layout: auto; }
.dashboard-grid td, .dashboard-grid th { white-space: nowrap; }
@media (max-width: 900px) { .dashboard-grid { grid-template-columns: 1fr; } }

/* ---- Detail ---- */
.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; }
.detail-grid > div:first-child { min-width: 0; }
.detail-grid .secondary { display: flex; flex-direction: column; gap: 16px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 16px; font-size: 14px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; color: var(--text); }

/* ---- Pagination ---- */
.pagination { display: flex; gap: 0; padding: 16px 0; justify-content: center; }
.pagination a, .pagination span {
  padding: 8px 14px; border: 1px solid var(--border-strong);
  text-decoration: none; color: var(--primary); font-size: 14px; background: #fff;
  min-width: 38px; text-align: center; font-weight: 600;
  margin-left: -1px;
}
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination a:hover { background: var(--primary-soft); }

/* ---- Item list ---- */
.item-list { list-style: none; margin: 0; padding: 0; }
.item-list li { padding: 14px 0; border-bottom: 1px solid var(--border-light); font-size: 14px; }
.item-list li:last-child { border-bottom: none; }
.item-list .meta { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ---- Items table ---- */
.items-table input, .items-table select { margin: 0; padding: 0 8px; font-size: 14px; height: 32px; }
.items-table th { font-size: 12px; }

/* ---- Row thumbnail ---- */
.row-thumb { display: block; width: 48px; height: 48px; border: 1px solid var(--border-light); background: var(--bg-alt); }
.row-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.row-thumb.empty { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 11px; cursor: default; }

/* ---- Customer banner ---- */
.customer-banner {
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  border-top: 4px solid var(--primary);
}
.customer-banner h2 {
  font-size: 12px; color: var(--text-soft); font-weight: 700;
  margin: 0; letter-spacing: 0.06em; text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 6px;
}
.customer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 18px 28px; }
.cust-cell { min-width: 0; }
.cust-label {
  font-size: 12px; color: var(--text-soft); margin-bottom: 4px;
  font-weight: 600;
}
.cust-value { font-size: 16px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cust-value a { color: var(--primary); }

/* ---- Gallery ---- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.gallery.gallery-sm { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px; }
.gallery.gallery-sm .gallery-name { display: none; }
.gallery-item { position: relative; border: 1px solid var(--border-light); overflow: hidden; background: var(--bg-alt); }
.gallery-thumb {
  display: block; width: 100%; aspect-ratio: 1; overflow: hidden;
  background:
    linear-gradient(45deg, #e7e7e7 25%, transparent 25%),
    linear-gradient(-45deg, #e7e7e7 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e7e7e7 75%),
    linear-gradient(-45deg, transparent 75%, #e7e7e7 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-name {
  padding: 6px 10px; font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-top: 1px solid var(--border-light); background: #fff;
}
.gallery-del {
  position: absolute; top: 4px; right: 4px;
  width: 24px; height: 24px;
  border: 1px solid #fff; background: var(--accent-red); color: #fff;
  cursor: pointer; font-size: 14px; line-height: 1;
  opacity: 0; transition: opacity 0.15s; z-index: 2;
  display: flex; align-items: center; justify-content: center;
}
.gallery-item:hover .gallery-del { opacity: 1; }

/* ---- Lightbox ---- */
.lightbox-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.92); display: flex; align-items: center; justify-content: center; z-index: 2000; cursor: zoom-out; padding: 32px; }
.lightbox-overlay img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox-close { position: absolute; top: 20px; right: 20px; width: 40px; height: 40px; border: 0; background: #fff; color: var(--text); font-size: 18px; cursor: pointer; }

/* ---- Modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; z-index: 1000; opacity: 0; transition: opacity 0.15s ease; padding: 16px; }
.modal-overlay.open { opacity: 1; }
.modal {
  background: #fff;
  border-top: 8px solid var(--primary);
  max-width: 460px; width: 100%; padding: 28px;
  transform: translateY(-8px); transition: transform 0.15s ease;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-body { font-size: 15px; line-height: 1.6; color: var(--text); margin-bottom: 24px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-actions .btn { min-width: 84px; }

/* ---- AI 邮件 / 图片识别卡 ---- */
.ai-extract-card {
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  border-top: 4px solid var(--primary);
}
.ai-extract-card .ai-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.ai-extract-card .ai-head h2 { margin: 0; font-size: 17px; }
.ai-extract-card textarea { font-family: var(--font-mono); font-size: 13px; }
.ai-preview { margin-top: 16px; padding: 14px 16px; background: #fff; border-left: 4px solid var(--success); }
.ai-preview h3 { margin: 0 0 8px; font-size: 14px; color: var(--success); font-weight: 700; }
.ai-inq-box { font-size: 14px; }
.kv-inline { margin: 4px 0; }
.kv-inline b { color: var(--muted); font-weight: 600; margin-right: 4px; }
.ai-products { margin: 4px 0 0 0; padding-left: 20px; font-size: 14px; }
.ai-products li { padding: 2px 0; }

/* ---- 经营数据 ---- */
.biz-section { margin-bottom: 10px; }
.biz-section-header { margin: 0 0 6px; }
.biz-section-header h2 { font-size: 14px; margin: 0; font-weight: 700; }
.biz-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin-bottom: 8px; border: 1px solid var(--border-light); }
.biz-card { background: #fff; border-right: 1px solid var(--border-light); border-top: 3px solid var(--primary); padding: 10px 14px; }
.biz-card:last-child { border-right: none; }
.biz-card.highlight { background: var(--primary-soft); }
.biz-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.biz-period { font-weight: 700; color: var(--text); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.biz-delta { font-size: 12px; padding: 2px 8px; border-radius: 0; font-weight: 700; }
.delta-up      { background: #fff; color: var(--success); border: 1px solid var(--success); }
.delta-down    { background: #fff; color: var(--danger);  border: 1px solid var(--danger); }
.delta-neutral { background: #fff; color: var(--muted);   border: 1px solid var(--muted); }
.biz-delta-inline {
  display: inline-flex; align-items: baseline; gap: 6px;
  font-size: 13px; font-weight: 700;
  margin-left: 12px; vertical-align: 8px;
  font-variant-numeric: tabular-nums;
}
.biz-delta-inline.delta-up      { background: transparent; border: 0; color: var(--success); padding: 0; }
.biz-delta-inline.delta-down    { background: transparent; border: 0; color: var(--danger);  padding: 0; }
.biz-delta-inline.delta-neutral { background: transparent; border: 0; color: var(--muted);   padding: 0; }
.biz-delta-inline .muted { font-size: 11px; }
.biz-count { font-size: 22px; font-weight: 700; color: var(--primary); line-height: 1; margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.biz-count .unit { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.biz-amounts { border-top: 1px solid var(--border-light); padding-top: 6px; }
.biz-amount-row { display: flex; justify-content: space-between; font-size: 12px; padding: 1px 0; }
.biz-amount-row .ccy { color: var(--muted); font-size: 12px; }
.biz-amount-row .amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.biz-vs { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border-light); color: var(--muted); font-size: 11px; }
.biz-diff-card { margin-top: 4px; }
.biz-diff-table { width: 100%; }
.biz-diff-table th { font-size: 12px; }
.biz-diff-table td { font-variant-numeric: tabular-nums; }
.biz-diff-table td.delta-up,
.biz-diff-table td.delta-down,
.biz-diff-table td.delta-neutral { font-weight: 700; background: transparent; padding-left: 14px; border: 0; }
.biz-diff-table td.delta-up { color: var(--success); }
.biz-diff-table td.delta-down { color: var(--danger); }
@media (max-width: 768px) { .biz-grid { grid-template-columns: 1fr; } }

/* ---- 自定义 Select ---- */
select.cs-native { position: absolute !important; top: 0; left: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; opacity: 0; pointer-events: none; z-index: 0; }
.custom-select { position: relative; width: 100%; margin-top: 6px; font-size: 16px; }
.custom-select > .cs-trigger { position: relative; z-index: 1; }
.custom-select.disabled { opacity: 0.6; }
.cs-trigger {
  width: 100%;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  height: 40px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: 0;
  background: #fff; color: var(--text);
  font-size: 16px; font-family: inherit; text-align: left; cursor: pointer;
}
.cs-trigger:hover:not(:disabled) { border-color: var(--text); }
.cs-trigger:focus, .cs-trigger.open {
  outline: none;
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);   /* 加深边框而不向外扩，保持与按钮等高 */
}
.cs-trigger:disabled { background: var(--bg-alt); cursor: not-allowed; color: var(--muted); }
.cs-trigger.placeholder .cs-value { color: #757575; }
.cs-value { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.cs-arrow { color: var(--text-soft); font-size: 14px; transition: transform 0.15s; }
.cs-trigger.open .cs-arrow { transform: rotate(180deg); }

.cs-menu {
  position: absolute; top: calc(100% + 2px); left: 0; right: 0;
  max-height: 480px;          /* 不设 min-width，让菜单与触发器同宽 */
  background: #fff; border: 1px solid var(--border-strong); border-radius: 0;
  z-index: 100; flex-direction: column; overflow: hidden;
}
.cs-menu[hidden] { display: none !important; }
.cs-menu:not([hidden]) { display: flex; }
.custom-select.drop-up .cs-menu { top: auto; bottom: calc(100% + 2px); }
.cs-search { margin: 8px; padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: 0; font-size: 14px; font-family: inherit; width: auto; }
.cs-search:focus { outline: 2px solid var(--accent-gold); }
.cs-options { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.cs-option {
  padding: 13px 18px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.3;
  border-bottom: 1px solid var(--border-light);
}
.cs-option:last-child { border-bottom: none; }
.cs-option.highlighted { background: var(--primary-soft); }
.cs-option.selected { color: #fff; font-weight: 700; background: var(--primary); }
.cs-option.disabled { color: var(--muted); cursor: not-allowed; }
.cs-empty { padding: 14px; text-align: center; color: var(--muted); font-size: 14px; }

.filters .custom-select, .store-switch .custom-select { width: auto; min-width: 180px; margin: 0; display: inline-block; }
.store-switch .cs-trigger { height: 32px; padding: 0 10px; font-size: 13px; background: var(--primary-dark); color: #fff; border-color: #fff; }
.store-switch .cs-arrow { color: #fff; }
.items-table .custom-select { margin: 0; }
.items-table .cs-trigger { height: 32px; padding: 0 8px; font-size: 14px; }
.items-table input { height: 32px; }

@media (max-width: 768px) {
  .detail-grid { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .nav-links { display: none; }
}

/* ──────── 待办 ──────── */
.todo-card {
  background: #fff;
  border: 1px solid var(--border-light);
  border-left: 8px solid var(--warning);
  border-top: 1px solid var(--border-light);
}
.todo-card h2 { color: var(--text); }
.todo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.todo-section { background: var(--bg-alt); padding: 14px 16px; border: 1px solid var(--border-light); }
.todo-section h3 {
  font-size: 12px; margin: 0 0 10px; color: var(--text); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.todo-list { list-style: none; padding: 0; margin: 0; }
.todo-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border-light); font-size: 14px; }
.todo-list li:last-child { border-bottom: none; }
.todo-list a { font-weight: 700; color: var(--primary); }
.todo-meta { color: var(--muted); font-size: 13px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.todo-due { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.todo-due.overdue { color: var(--danger); font-weight: 700; }

/* ──────── ChatGPT 浮窗 ──────── */
#gpt-chat-widget { position: fixed; right: 28px; bottom: 28px; z-index: 9999; font-size: 14px; }
#gpt-chat-toggle {
  display: flex; align-items: center; gap: 8px;
  background: var(--primary); color: #fff; border: 0; border-radius: 0;
  padding: 14px 22px; font-size: 14px; font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer; transition: background 0.1s;
}
#gpt-chat-toggle:hover { background: var(--primary-darker); }

#gpt-chat-panel {
  position: fixed; right: 28px; bottom: 28px;
  width: 460px; max-width: calc(100vw - 32px);
  height: 660px; max-height: calc(100vh - 56px);
  background: #fff; border-radius: 0;
  border: 1px solid var(--border-strong);
  display: flex; flex-direction: column;
  overflow: hidden;
}
#gpt-chat-panel[hidden] { display: none !important; }
#gpt-chat-panel.drag-over { box-shadow: 0 0 0 4px var(--accent-gold); }

.gpt-chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  background: var(--primary-dark); color: #fff; font-size: 14px;
  border-bottom: 4px solid var(--primary);
}
.gpt-chat-header strong { font-weight: 700; letter-spacing: 0.01em; }
.gpt-chat-header-actions { display: flex; gap: 4px; }
.gpt-chat-header button {
  background: rgba(255,255,255,0.12); color: #fff; border: 0;
  width: 30px; height: 30px; border-radius: 0;
  cursor: pointer; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.gpt-chat-header button:hover { background: rgba(255,255,255,0.25); }

.gpt-chat-messages {
  flex: 1; overflow-y: auto; padding: 18px;
  background: var(--bg-alt);
  display: flex; flex-direction: column; gap: 14px;
}
.gpt-chat-empty { color: var(--muted); text-align: center; padding: 48px 16px; font-size: 14px; line-height: 1.7; }

.gpt-msg { display: flex; flex-direction: column; gap: 4px; max-width: 95%; }
.gpt-msg-user { align-self: flex-end; align-items: flex-end; }
.gpt-msg-assistant { align-self: flex-start; }
.gpt-msg-role { font-size: 11px; color: var(--muted); padding: 0 4px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.gpt-msg-body { padding: 12px 14px; border-radius: 0; line-height: 1.6; word-break: break-word; border: 1px solid var(--border-light); }
.gpt-msg-body p { margin: 0; }
.gpt-msg-body p + p { margin-top: 8px; }
.gpt-msg-body pre { background: #1b1b1b; color: #e5e7eb; padding: 10px 12px; border-radius: 0; font-size: 12px; overflow-x: auto; margin: 6px 0; }
.gpt-msg-body code { background: var(--bg-alt); padding: 1px 5px; font-size: 13px; font-family: var(--font-mono); }
.gpt-msg-user .gpt-msg-body { background: var(--primary); color: #fff; border-color: var(--primary); }
.gpt-msg-user .gpt-msg-body code { background: rgba(255,255,255,0.18); color: #fff; }
.gpt-msg-assistant .gpt-msg-body { background: #fff; }
.gpt-msg-err .gpt-msg-body { background: #fef2f2; border-color: var(--danger); color: var(--danger); }
.gpt-msg-files { font-size: 12px; color: var(--muted); padding: 0 4px; display: inline-flex; align-items: center; gap: 4px; }

.gpt-chat-files {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 10px 14px; background: var(--bg-alt); border-top: 1px solid var(--border-light);
}
.gpt-file-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; border: 1px solid var(--border-strong); border-radius: 0;
  padding: 4px 10px 4px 12px; font-size: 12px;
}
.gpt-file-size { color: var(--muted); font-size: 11px; }
.gpt-file-x { background: transparent; border: 0; cursor: pointer; padding: 0 4px; font-size: 14px; line-height: 1; color: var(--muted); }
.gpt-file-x:hover { color: var(--danger); }

.gpt-chat-input { display: flex; align-items: flex-end; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border-light); background: #fff; }
.gpt-chat-attach { background: transparent; border: 1px solid var(--border-strong); width: 40px; height: 40px; border-radius: 0; cursor: pointer; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; color: var(--text); }
.gpt-chat-attach:hover { background: var(--bg-alt); }
.gpt-chat-input textarea {
  flex: 1; resize: none;
  border: 1px solid var(--border-strong); border-radius: 0;
  padding: 10px 12px; font-size: 14px; font-family: inherit;
  line-height: 1.6; max-height: 240px; min-height: 72px;
  width: auto; margin: 0;
}
.gpt-chat-send {
  background: var(--primary); color: #fff; border: 0;
  padding: 0 22px; border-radius: 0;
  font-size: 14px; font-weight: 700; cursor: pointer; flex-shrink: 0; height: 40px;
  letter-spacing: 0.02em;
}
.gpt-chat-send:hover { background: var(--primary-darker); }
.gpt-chat-send:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 480px) {
  #gpt-chat-panel { right: 12px; left: 12px; width: auto; bottom: 12px; height: calc(100vh - 24px); }
  #gpt-chat-widget { right: 12px; bottom: 12px; }
  #gpt-chat-toggle .gpt-label { display: none; }
}

/* 工具调用痕迹 */
.gpt-msg-tools { display: flex; flex-direction: column; gap: 4px; margin-bottom: 4px; }
.gpt-tool-call {
  font-size: 11px; padding: 5px 10px; border-radius: 0;
  background: var(--primary-soft); color: var(--primary-dark); border-left: 3px solid var(--primary);
  font-family: var(--font-mono);
  word-break: break-all;
}
.gpt-tool-call.err { background: #fee; color: #7f1d1d; border-left-color: var(--danger); }
.gpt-tool-call code { background: transparent; padding: 0; font-weight: 700; }
