/* =========================================================
   OZON / WB 经营中控 — 护眼柔和浅色主题
   暖米白底 + 雾蓝/鼠尾草绿 + 降低对比度
   ========================================================= */

:root {
  /* 基底色 — 暖米白系，减少蓝光，护眼柔和 */
  --bg-0: #f3efe6;              /* 侧边栏底（暖灰白） */
  --bg-1: #faf8f3;              /* 主背景（暖米白） */
  --bg-2: #ffffff;              /* 面板背景（柔白） */
  --bg-3: #f4efe5;              /* 交互/高亮底色（浅米） */
  --bg-4: #ebe5d8;              /* 分隔与输入框底 */
  --line: rgba(120, 110, 90, 0.12);
  --line-strong: rgba(120, 110, 90, 0.22);

  /* 文字 — 深炭灰系，避免纯黑刺眼 */
  --ink-1: #3d3a35;             /* 主文字（炭灰） */
  --ink-2: #6b665e;             /* 次级文字（暖灰） */
  --ink-3: #948e84;             /* 说明文字（浅暖灰） */
  --ink-4: #b8b1a5;             /* 最弱（米灰） */

  /* 品牌色 — 雾蓝（沉稳不刺眼）+ 柔和鼠尾草绿 */
  --brand: #6b8eaf;             /* 雾蓝主色 */
  --brand-dark: #547a98;        /* 深一档雾蓝 */
  --brand-soft: rgba(107, 142, 175, 0.12);
  --brand-ring: rgba(107, 142, 175, 0.28);
  --accent-sage: #7ba087;       /* 鼠尾草绿 */
  --accent-sage-soft: rgba(123, 160, 135, 0.14);
  --accent-clay: #c08871;       /* 暖陶土（点缀） */
  --accent-gold: #c4a35a;       /* 柔金（活跃状态） */

  /* 状态色 — 哑光柔和，降低饱和度 */
  --green: #6f9e7e;             /* 鼠尾草绿（盈利） */
  --green-soft: rgba(111, 158, 126, 0.14);
  --red: #c47b6c;               /* 陶土红（亏损/警示） */
  --red-soft: rgba(196, 123, 108, 0.12);
  --orange: #cc9a5a;            /* 柔琥珀（提示） */
  --orange-soft: rgba(204, 154, 90, 0.14);

  /* 阴影 — 柔和暖色阴影，不要黑色压迫感 */
  --shadow-sm: 0 2px 8px rgba(120, 100, 70, 0.06);
  --shadow-md: 0 8px 24px rgba(120, 100, 70, 0.08);
  --shadow-lg: 0 20px 50px rgba(120, 100, 70, 0.12);

  /* 玻璃高光 — 柔和暖白 */
  --glow-top: linear-gradient(180deg, rgba(255, 252, 245, 0.7), transparent 50%);

  /* 其他 */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
}

/* Ozon keyword ranking */
.ranking-watch-panel { padding: 22px; }
.ranking-watch-toolbar { align-items: flex-start; }
.ranking-watch-toolbar-actions,
.ranking-watch-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ranking-watch-form {
  display: grid;
  grid-template-columns: minmax(260px, 1.2fr) minmax(240px, 1fr) auto auto;
  align-items: end;
  gap: 12px;
  margin: 18px 0 4px;
}
.ranking-watch-form label { margin: 0; }
.ranking-watch-form button { min-height: 44px; white-space: nowrap; }
.ranking-watch-table-wrap { margin-top: 14px; max-height: 560px; }
.ranking-watch-table { min-width: 1080px; }
.ranking-watch-table thead th { position: sticky; top: 0; z-index: 2; }
.ranking-watch-table th:first-child,
.ranking-watch-table td:first-child { width: 42px; text-align: center; }
.ranking-watch-table td > small,
.ranking-watch-table td button + small { display: block; margin-top: 4px; color: var(--ink-3); }
.ranking-watch-keyword,
.ranking-watch-history-link {
  border: 0;
  padding: 0;
  color: var(--brand-dark);
  background: transparent;
  box-shadow: none;
  font: inherit;
  font-weight: 750;
  text-align: left;
}
.ranking-watch-keyword:hover,
.ranking-watch-history-link:hover { color: var(--accent-sage); transform: none; box-shadow: none; }
.ranking-watch-rank { font-size: 18px; white-space: nowrap; }
.ranking-watch-change { font-weight: 750; white-space: nowrap; }
.ranking-watch-change.up { color: var(--green); }
.ranking-watch-change.down { color: var(--red); }
.ranking-watch-change.flat { color: var(--ink-3); }
.ranking-watch-error { max-width: 210px; color: var(--red) !important; overflow-wrap: anywhere; }
.ranking-watch-actions button { padding: 7px 10px; min-height: 34px; font-size: 12px; }
.ranking-watch-history {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-1);
}
.ranking-watch-history h4 { margin: 0; }
.ranking-watch-history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.ranking-watch-history-grid > div {
  display: grid;
  gap: 3px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-2);
}
.ranking-watch-history-grid span { color: var(--ink-3); font-size: 12px; }
.ranking-watch-history-grid strong { color: var(--ink-1); }
.ranking-section-heading { margin-bottom: 16px; }
.ranking-section-heading h3 { margin-bottom: 2px; }
.ranking-search-panel { padding: 22px; }
.ranking-form {
  display: grid;
  grid-template-columns: minmax(260px, 1.2fr) minmax(240px, 1fr) auto auto;
  align-items: end;
  gap: 14px;
}
.ranking-form label { margin: 0; }
.ranking-form button { min-height: 44px; white-space: nowrap; }
.ranking-collector-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(360px, 1.15fr);
  gap: 22px;
  margin-top: 16px;
}
.ranking-collector-grid ol { margin: 10px 0 0; padding-left: 22px; color: var(--ink-2); line-height: 1.8; }
.ranking-collector-grid code { color: var(--brand-dark); overflow-wrap: anywhere; }
.ranking-pair-box {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.48);
}
.ranking-pair-box textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; }
.ranking-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ranking-summary .metric strong { font-size: clamp(22px, 2vw, 32px); }
.ranking-thresholds {
  display: grid;
  grid-template-columns: repeat(5, minmax(145px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.ranking-threshold-card {
  display: grid;
  gap: 7px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.55);
}
.ranking-threshold-card > span,
.ranking-threshold-card small { color: var(--ink-3); }
.ranking-threshold-card > strong { color: var(--ink-1); font-size: 18px; }
.ranking-threshold-card b { color: var(--brand); }
.ranking-table-toolbar { align-items: end; }
.ranking-table-actions { display: flex; gap: 10px; align-items: center; }
.ranking-table-actions input { min-width: 270px; }
.ranking-table-wrap { max-height: 720px; }
.ranking-table { min-width: 1180px; }
.ranking-table thead th { position: sticky; top: 0; z-index: 2; }
.ranking-table td:first-child { width: 82px; }
.ranking-rank { display: block; font-size: 17px; }
.ranking-own-badge {
  display: inline-block;
  margin-top: 5px;
  padding: 2px 7px;
  border-radius: 999px;
  color: #075d44;
  background: #c8f5e4;
  font-size: 11px;
  white-space: nowrap;
}
.ranking-ad-badge {
  display: inline-block;
  margin-top: 5px;
  padding: 2px 7px;
  border-radius: 999px;
  color: #7b5013;
  background: #f8e6b7;
  font-size: 11px;
}
.ranking-own-row { background: rgba(31, 174, 125, 0.09); }
.ranking-product-cell { display: flex; gap: 10px; align-items: center; min-width: 330px; }
.ranking-product-cell > div { display: grid; gap: 5px; }
.ranking-product-cell a { color: var(--ink-1); font-weight: 650; line-height: 1.35; }
.ranking-product-cell small,
.ranking-table td > small { display: block; margin-top: 4px; color: var(--ink-3); }
.ranking-product-image {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 9px;
  object-fit: cover;
  background: #fff;
  border: 1px solid var(--line);
}
.ranking-old-price { text-decoration: line-through; }
.ranking-hashtag-toolbar { align-items: flex-start; }
.ranking-hashtag-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.ranking-hashtag-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin: 14px 0;
}
.ranking-hashtag-summary span {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-2);
  background: var(--bg-1);
  font-size: 12px;
}
.ranking-hashtag-summary strong { color: var(--ink-1); }
.ranking-hashtag-table-wrap { max-height: 520px; }
.ranking-hashtag-table { min-width: 680px; }
.ranking-hashtag-table th:first-child { width: 34%; }
.ranking-hashtag-ru { color: var(--brand-dark); font-size: 14px; }
.ranking-all-tags { margin-top: 16px; }
.ranking-all-tags summary {
  cursor: pointer;
  color: var(--brand-dark);
  font-weight: 700;
}
.ranking-all-tag-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 9px;
  margin-top: 12px;
  max-height: 620px;
  overflow: auto;
}
.ranking-all-tag {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 8px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-1);
}
.ranking-all-tag b { overflow-wrap: anywhere; color: var(--ink-1); }
.ranking-all-tag small { grid-column: 1; color: var(--ink-3); }
.ranking-all-tag em { grid-column: 2; grid-row: 1 / span 2; align-self: center; color: var(--brand-dark); font-style: normal; font-weight: 700; }

@media (max-width: 1180px) {
  .ranking-watch-form { grid-template-columns: 1fr 1fr; }
  .ranking-form { grid-template-columns: 1fr 1fr; }
  .ranking-collector-grid { grid-template-columns: 1fr; }
  .ranking-thresholds { grid-template-columns: repeat(3, minmax(145px, 1fr)); }
}
@media (max-width: 760px) {
  .ranking-watch-form,
  .ranking-form,
  .ranking-summary,
  .ranking-thresholds { grid-template-columns: 1fr; }
  .ranking-table-toolbar,
  .ranking-table-actions,
  .ranking-hashtag-toolbar,
  .ranking-hashtag-actions,
  .ranking-watch-toolbar,
  .ranking-watch-toolbar-actions { align-items: stretch; flex-direction: column; }
  .ranking-table-actions input { min-width: 0; width: 100%; }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background:
    radial-gradient(1200px 800px at 85% -10%, rgba(107, 142, 175, 0.05), transparent 60%),
    radial-gradient(1000px 700px at -10% 110%, rgba(123, 160, 135, 0.04), transparent 55%),
    var(--bg-1);
  color: var(--ink-1);
  font-family: "SF Pro Display", "PingFang SC", "Microsoft YaHei", -apple-system, Segoe UI, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
  line-height: 1.6;
  letter-spacing: 0.01em;
}

/* ========== 布局框架 ========== */
.app {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

/* ========== 侧边栏 ========== */
aside {
  background:
    linear-gradient(180deg, rgba(107, 142, 175, 0.04), transparent 30%),
    var(--bg-0);
  border-right: 1px solid var(--line);
  padding: 26px 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

aside > section:first-child {
  padding: 4px 6px 18px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-1);
  letter-spacing: 0.22em;
  font-size: 11.5px;
  font-weight: 800;
}

.brand-mark::before {
  content: "";
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent-sage) 100%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.4) inset,
    0 4px 12px rgba(107, 142, 175, 0.25);
  display: inline-block;
}

/* 导航按钮 */
nav {
  display: grid;
  grid-auto-rows: auto;
  gap: 4px;
  margin-top: 4px;
}

/* 侧边栏功能列业务顺序（与 4 个 JS 注入顺序解耦）
   order 数值越小越靠前；settings 放最后 */
.tab-btn[data-tab="dashboard"]   { order: 10; }
.tab-btn[data-tab="orderProfit"] { order: 20; }
.tab-btn[data-tab="costs"]       { order: 30; }
.tab-btn[data-tab="inventory"]   { order: 32; }
.tab-btn[data-tab="sourcing"]    { order: 35; }
.tab-btn[data-tab="listing"]     { order: 38; }
.tab-btn[data-tab="promotions"]  { order: 39; }
.tab-btn[data-tab="ads"]         { order: 40; }
.tab-btn[data-tab="analytics"]   { order: 45; }
.tab-btn[data-tab="aiStudio"]    { order: 48; }
.tab-btn[data-tab="ozonRanking"] { order: 49; }
.tab-btn[data-tab="competitors"] { order: 50; }
.tab-btn[data-tab="settings"]    { order: 90; margin-top: 10px; }

/* 给 nav 留出 4px 左边距，让 active 状态的指示条显示出来 */
nav {
  padding-left: 4px;
  margin-left: -4px;
}

.tab-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-2);
  padding: 11px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-align: left;
  line-height: 1.2;
  min-height: 44px;
  transition: all 0.18s ease;
}
/* 选中态左侧高亮指示条 */
.tab-btn.active::before {
  content: "";
  position: absolute;
  left: -2px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--brand), var(--accent-sage));
  box-shadow: 0 0 8px rgba(107, 142, 175, 0.4);
}

.tab-btn span {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(120, 110, 90, 0.06);
  font-size: 14px;
  color: var(--ink-3);
  transition: inherit;
  flex-shrink: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: clip;
}

.tab-btn:hover:not(.active) {
  background: rgba(120, 110, 90, 0.04);
  color: var(--ink-1);
}
.tab-btn:hover:not(.active) span {
  background: var(--brand-soft);
  color: var(--brand);
}

.tab-btn.active {
  background: linear-gradient(135deg, rgba(107, 142, 175, 0.14), rgba(123, 160, 135, 0.08));
  color: var(--ink-1);
  border-color: rgba(107, 142, 175, 0.2);
  box-shadow: 0 2px 10px rgba(107, 142, 175, 0.1);
}
.tab-btn.active span {
  background: linear-gradient(135deg, var(--brand), var(--accent-sage));
  color: #fff;
  box-shadow: 0 2px 8px rgba(107, 142, 175, 0.3);
}

.live-badge {
  margin-left: auto;
  color: var(--accent-gold);
  background: rgba(196, 163, 90, 0.14);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

/* 侧边卡片（实时汇率） */
.side-card {
  margin-top: auto;
  background:
    var(--glow-top),
    linear-gradient(180deg, rgba(107, 142, 175, 0.05), transparent 60%),
    var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.6;
  box-shadow: var(--shadow-sm);
}
.side-card > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 600;
  letter-spacing: 0.03em;
}
.side-card > div:nth-child(2) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ink-1);
  font-size: 12px;
  padding-top: 2px;
}
.side-card strong {
  display: block;
  font-size: 24px;
  font-weight: 800;
  margin-top: 6px;
  letter-spacing: -0.01em;
  color: var(--brand-dark);
}
.connection-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--green);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.05em;
}
.connection-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(111, 158, 126, 0.18);
  animation: pulse-soft 2s ease-in-out infinite;
}
@keyframes pulse-soft {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.85); }
}

/* ========== 主内容区 ========== */
main {
  padding: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-content: start;
  min-width: 0;
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  height: 66px;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, var(--topbar-a, rgba(250, 248, 243, 0.9)), var(--topbar-b, rgba(250, 248, 243, 0.7)));
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.topbar h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink-1);
  text-transform: uppercase;
  position: relative;
  padding-left: 14px;
}
.topbar h2::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 16px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--brand), var(--accent-sage));
}

.tab { display: none; padding: 28px 32px 48px; gap: 20px; }
.tab.active { display: grid; }

/* ========== 通用面板 ========== */
.panel {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px 24px;
  min-width: 0;
  overflow: hidden;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.panel:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}
.panel::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(107, 142, 175, 0.15), transparent);
  pointer-events: none;
}

/* ========== Dashboard 头部快报 ========== */
.dashboard-brief {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 22px 26px;
  background:
    radial-gradient(600px 200px at 100% 0%, rgba(107, 142, 175, 0.08), transparent 60%),
    var(--glow-top),
    var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.dashboard-brief h2 {
  font-size: 18px;
  color: var(--ink-1);
  font-weight: 800;
  letter-spacing: 0.02em;
  margin: 0;
}
.dashboard-brief p {
  margin: 4px 0 0;
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 500;
}

.live-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink-1);
  background: var(--green-soft);
  border: 1px solid rgba(111, 158, 126, 0.25);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.live-chip span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(111, 158, 126, 0.18);
  animation: pulse-dot 1.6s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 4px rgba(111, 158, 126, 0.22); }
  50% { opacity: 0.6; transform: scale(0.75); box-shadow: 0 0 0 8px rgba(111, 158, 126, 0.05); }
}

/* 摘要范围面板 */
.summary-panel {
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.summary-panel h3 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--ink-1);
}
.summary-panel p {
  margin: 0;
  color: var(--ink-3);
  font-size: 12.5px;
  font-weight: 500;
}

/* 分段控件（通用） */
.range-pills, .period-tabs, .segmented.small {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.range-pills button,
.period-tabs button,
.segmented.small button {
  background: transparent;
  color: var(--ink-2);
  padding: 7px 13px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: all 0.15s ease;
}
.range-pills button:hover:not(.active),
.period-tabs button:hover:not(.active),
.segmented.small button:hover:not(.active) {
  color: var(--ink-1);
  background: rgba(120, 110, 90, 0.05);
}
.range-pills button.active,
.period-tabs button.active,
.segmented.small button.active {
  background: linear-gradient(135deg, var(--brand), var(--accent-sage));
  color: #fff;
  box-shadow: 0 2px 8px rgba(107, 142, 175, 0.25);
}

/* ========== 指标卡 / KPI ========== */
.grid { display: grid; gap: 20px; }
.metrics { grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 20px; }

.metric {
  position: relative;
  min-height: 158px;
  padding: 24px 26px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    radial-gradient(500px 200px at 100% 0%, rgba(107, 142, 175, 0.06), transparent 55%),
    var(--glow-top),
    var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.metric:hover {
  transform: translateY(-2px);
  border-color: rgba(107, 142, 175, 0.22);
  box-shadow: var(--shadow-md);
}
.metric::after {
  content: "";
  position: absolute;
  right: -20px; bottom: -20px;
  width: 140px; height: 140px;
  background: radial-gradient(circle, rgba(107, 142, 175, 0.08), transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.metric span {
  color: var(--ink-3);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-weight: 700;
}

.metric strong {
  display: block;
  font-size: 34px;
  margin-top: 10px;
  letter-spacing: -0.02em;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ink-1);
}
.metric strong small {
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 600;
  margin-left: 6px;
  letter-spacing: 0.03em;
}

.metric-sub {
  color: var(--ink-3);
  font-size: 12.5px;
  font-weight: 500;
  margin-top: 14px;
}
.metric-sub b { color: var(--ink-1); font-weight: 700; }

.metric-split {
  display: flex;
  height: 6px;
  background: var(--bg-3);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 14px;
}
.metric-split i {
  display: block;
  width: 66%;
  background: linear-gradient(90deg, var(--brand), var(--accent-sage));
}
.metric-split em {
  display: block;
  width: 34%;
  background: linear-gradient(90deg, var(--accent-sage), var(--accent-clay));
}

/* 利润卡特殊处理 */
.metric.profit-card {
  border-color: rgba(111, 158, 126, 0.22);
  background:
    radial-gradient(500px 200px at 100% 0%, rgba(111, 158, 126, 0.08), transparent 55%),
    var(--glow-top),
    var(--bg-2);
  box-shadow: 0 2px 12px rgba(111, 158, 126, 0.06);
}
.metric.profit-card strong {
  color: var(--green);
}
.metric.profit-card::after {
  background: radial-gradient(circle, rgba(111, 158, 126, 0.12), transparent 70%);
}

/* 广告 KPI */
.panel.metric {
  padding: 22px;
}

/* ========== 通用工具条 ========== */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.toolbar h3 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--ink-1);
}
.toolbar p,
.section-note {
  margin: 4px 0 0;
  color: var(--ink-3);
  font-size: 12.5px;
  font-weight: 500;
}
.status { color: var(--ink-3); font-size: 12.5px; font-weight: 500; }
.table-status {
  margin: 0 0 12px;
  color: var(--ink-3);
  font-size: 12.5px;
  font-weight: 500;
}

/* ========== 图表面板 ========== */
.chart-wrap {
  position: relative;
  border-radius: var(--radius-md);
  background: var(--bg-1);
  border: 1px solid var(--line);
  overflow: hidden;
}
canvas { width: 100%; display: block; }

.chart-controls {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.legend {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.legend-line {
  width: 26px;
  height: 3px;
  border-radius: 999px;
  background: var(--brand);
}
.legend-line.light { background: var(--accent-sage); }
.legend-line.dashed {
  height: 0;
  background: transparent;
  border-top: 2px dashed var(--ink-3);
}
.legend-line.green { background: var(--green); }
.legend-line.yellow { background: var(--accent-gold); }
.legend-bar {
  width: 13px;
  height: 13px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--brand), var(--accent-sage));
  box-shadow: 0 1px 3px rgba(107, 142, 175, 0.2);
}

.chart-select {
  position: relative;
}
.chart-select button {
  background: var(--bg-2);
  color: var(--ink-1);
  padding: 9px 14px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.chart-select button:hover {
  border-color: var(--brand-ring);
  background: var(--bg-3);
}

.chart-menu {
  position: absolute;
  right: 0;
  top: 44px;
  display: none;
  width: 280px;
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 10px;
  z-index: 15;
}
.chart-menu.open { display: grid; gap: 10px; }
.menu-group {
  display: grid;
  gap: 6px;
  padding: 6px 8px 10px;
  border-bottom: 1px solid var(--line);
}
.menu-group:last-child { border-bottom: 0; padding-bottom: 4px; }
.menu-label {
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.menu-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink-2);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.12s ease;
}
.menu-option:hover { background: var(--bg-3); color: var(--ink-1); }
.menu-option.active { color: var(--brand-dark); background: var(--brand-soft); font-weight: 600; }
.menu-option.active::after {
  content: "✓";
  color: var(--brand-dark);
  font-weight: 800;
}

.chart-tooltip {
  position: absolute;
  display: none;
  min-width: 180px;
  pointer-events: none;
  background: rgba(255, 252, 245, 0.97);
  backdrop-filter: blur(8px);
  color: var(--ink-1);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.65;
  box-shadow: var(--shadow-lg);
  z-index: 20;
}
.chart-tooltip b { color: var(--brand-dark); font-weight: 700; }

/* ========== 表格 ========== */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-2);
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0;
}

th {
  background: var(--bg-3);
  color: var(--ink-3);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 14px 12px;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th:first-child { border-left: none; }

td {
  padding: 13px 12px;
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
  color: var(--ink-1);
  border-bottom: 1px solid var(--line);
  font-weight: 500;
}
tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: var(--bg-3); }
tbody tr:last-child td { border-bottom: none; }

.money {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-weight: 600;
  color: var(--ink-1);
}
.muted-cell {
  color: var(--ink-3);
  font-weight: 500;
  text-align: center !important;
  padding: 32px 12px !important;
}
.sku { color: var(--ink-3); font-size: 12px; margin-top: 3px; }
.positive { color: var(--green); font-weight: 700; }
.negative { color: var(--red); font-weight: 700; }
.change-up { color: var(--red); font-weight: 700; }
.change-down { color: var(--green); font-weight: 700; }

/* 店铺概览表格 */
.store-overview-panel .table-wrap { max-height: 540px; }
.store-table td strong { color: var(--ink-1); font-weight: 700; }

/* ========== 表单控件 ========== */
label {
  display: grid;
  gap: 7px;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13.5px;
  outline: none;
  background: var(--bg-2);
  color: var(--ink-1);
  font: inherit;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder, textarea::placeholder { color: var(--ink-4); }
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  background: var(--bg-2);
  box-shadow: 0 0 0 3px var(--brand-ring);
}
select {
  cursor: pointer;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}
form { display: grid; gap: 14px; }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cols-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 720px) { .cols-3 { grid-template-columns: 1fr; } }

/* ========== 产品成本：总览范围 & 动态字段 ========== */
.cost-scope-panel .toolbar { flex-wrap: wrap; gap: 16px; }
.cost-scope-pills { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.cost-scope-pills .inline-select select { width: 150px; }
.cost-dynamic-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cost-dynamic-fields:empty { display: none; }
.cost-fee-hint {
  display: flex; align-items: center;
  background: var(--bg-3);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--ink-3);
  font-size: 12.5px;
}
.cost-fee-hint.configured { color: var(--accent-sage); border-color: var(--accent-sage); }
.inventory-panel {
  display: grid;
  gap: 14px;
}
.inventory-toolbar {
  align-items: flex-start;
}
.inventory-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.inventory-controls {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(170px, 1fr) minmax(240px, 1.4fr) minmax(120px, .7fr) auto;
  gap: 12px;
  align-items: end;
}
.inventory-controls button {
  height: 42px;
}
.inventory-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-3);
  color: var(--ink-2);
}
.inventory-loading[hidden] {
  display: none;
}
.inventory-loading span {
  width: 18px;
  height: 18px;
  border: 3px solid var(--line-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: inventory-spin .8s linear infinite;
}
@keyframes inventory-spin { to { transform: rotate(360deg); } }
.inventory-table-wrap {
  max-height: 620px;
}
.inventory-table {
  table-layout: fixed;
  min-width: 1340px;
}
.inventory-table th:first-child,
.inventory-table td:first-child {
  width: 44px;
  text-align: center;
}
.inventory-table th:nth-child(2),
.inventory-table td:nth-child(2) {
  width: 430px;
  max-width: 430px;
}
.inventory-table th:nth-child(3),
.inventory-table td:nth-child(3) {
  width: 126px;
}
.inventory-table th:nth-child(4),
.inventory-table td:nth-child(4) {
  width: 150px;
}
.inventory-table th:nth-child(5),
.inventory-table td:nth-child(5),
.inventory-table th:nth-child(6),
.inventory-table td:nth-child(6) {
  width: 112px;
}
.inventory-table th:nth-child(7),
.inventory-table td:nth-child(7) {
  width: 210px;
}
.inventory-table th:nth-child(8),
.inventory-table td:nth-child(8),
.inventory-table th:nth-child(9),
.inventory-table td:nth-child(9) {
  width: 92px;
}
.inventory-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
  padding: 0;
}
.inventory-sort {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  letter-spacing: inherit;
  padding: 0;
  text-align: left;
  white-space: nowrap;
}
.inventory-sort.active {
  color: var(--brand);
}
.inventory-product {
  display: grid;
  grid-template-columns: 46px minmax(160px, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
}
.inventory-product-copy {
  min-width: 0;
}
.inventory-product-name {
  display: -webkit-box;
  max-height: 42px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.inventory-product .sku {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inventory-product-img,
.inventory-product-placeholder {
  width: 46px;
  height: 46px;
  border-radius: 6px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  object-fit: cover;
}
.inventory-product-placeholder {
  display: grid;
  place-items: center;
  color: var(--ink-3);
  font-weight: 800;
  font-size: 12px;
}
@media (max-width: 1180px) {
  .inventory-controls {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 640px) {
  .inventory-controls {
    grid-template-columns: 1fr;
  }
}
.scope-chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-sage-soft);
  color: var(--accent-sage);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.cost-fee-import-box { grid-template-columns: minmax(160px, 200px) minmax(240px, 1fr) auto auto; }
@media (max-width: 720px) { .cost-fee-import-box { grid-template-columns: 1fr; } }

/* ========== 按钮 ========== */
button {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.primary {
  background: linear-gradient(135deg, var(--brand), var(--accent-sage));
  color: #fff;
  box-shadow: 0 2px 8px rgba(107, 142, 175, 0.22);
  font-weight: 700;
  letter-spacing: 0.02em;
}
.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(107, 142, 175, 0.32);
}

.secondary {
  background: var(--bg-3);
  color: var(--ink-1);
  border: 1px solid var(--line-strong);
  font-weight: 600;
}
.secondary:hover {
  background: var(--bg-4);
  border-color: var(--brand-ring);
  color: var(--ink-1);
}

.danger {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid rgba(196, 123, 108, 0.3);
  font-weight: 600;
}
.danger:hover {
  background: rgba(196, 123, 108, 0.2);
  color: #fff;
}

/* loading 按钮状态 */
.loading {
  background: var(--bg-3) !important;
  color: var(--ink-3) !important;
  cursor: progress !important;
  pointer-events: none;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

.actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ========== 总成本显示 ========== */
.total {
  background:
    radial-gradient(300px 120px at 0% 0%, rgba(107, 142, 175, 0.08), transparent 60%),
    var(--bg-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.total span {
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.total strong {
  font-size: 24px;
  color: var(--ink-1);
  font-weight: 800;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

/* ========== 搜索框 ========== */
.search {
  max-width: 360px;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23948e84' stroke-width='2.5' stroke-linecap='round'><circle cx='11' cy='11' r='7'/><path d='m20 20-4.3-4.3'/></svg>");
  background-repeat: no-repeat;
  background-position: 12px center;
  padding-left: 38px;
}

/* ========== 导入区 & 店铺筛选 ========== */
.import-box {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(260px, 1fr) auto auto;
  gap: 14px;
  align-items: end;
  padding: 18px;
  background: var(--bg-3);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
}

.inline-select {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
}
.inline-select select { width: 220px; }

.ad-filterbar {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-left: auto;
}

.switch-line {
  height: 36px;
  display: flex !important;
  align-items: center;
  gap: 8px !important;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  white-space: nowrap;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 12.5px;
}
.switch-line input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: var(--brand);
}

/* ========== 日期选择器 ========== */
.date-range-picker { position: relative; }

.date-range-button {
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  color: var(--ink-1);
  min-width: 240px;
  text-align: left;
  font-weight: 500;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
}
.date-range-button:hover {
  border-color: var(--brand-ring);
  background: var(--bg-3);
}

.date-range-panel {
  position: absolute;
  right: 0;
  top: 48px;
  display: none;
  grid-template-columns: minmax(560px, 1fr) 92px;
  gap: 14px;
  width: 720px;
  padding: 16px;
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 30;
}
.date-range-panel.open { display: grid; }

.date-range-main { display: grid; gap: 12px; }

.date-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.date-display {
  width: 100%;
  height: 48px;
  background: var(--bg-3);
  border: 1px solid var(--line-strong);
  color: var(--ink-1);
  text-align: left;
  font-weight: 700;
  border-radius: var(--radius-sm);
  padding: 0 14px;
}
.date-display:hover { border-color: var(--brand-ring); }

.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ink-1);
  font-size: 13px;
  font-weight: 700;
  padding: 4px 8px;
}
.calendar-head button {
  width: 32px;
  height: 32px;
  padding: 0;
  background: var(--bg-3);
  color: var(--ink-2);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.calendar-head button:hover {
  background: var(--bg-4);
  color: var(--ink-1);
  border-color: var(--brand-ring);
}

.calendar-months {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.calendar-month {
  display: grid;
  gap: 8px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px;
}
.calendar-title {
  text-align: center;
  color: var(--ink-1);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.calendar-week, .calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.calendar-week span {
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  padding: 4px 0;
}
.calendar-day {
  height: 32px;
  padding: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-1);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
}
.calendar-day:hover {
  background: var(--brand-soft);
  color: var(--brand-dark);
}
.calendar-day.muted { color: var(--ink-4); }
.calendar-day.in-range {
  background: var(--brand-soft);
  color: var(--brand-dark);
  border-radius: 0;
}
.calendar-day.selected {
  background: linear-gradient(135deg, var(--brand), var(--accent-sage));
  color: #fff;
  box-shadow: 0 3px 8px rgba(107, 142, 175, 0.3);
  font-weight: 700;
}
.calendar-day.today {
  outline: 1px solid var(--brand-ring);
  outline-offset: -1px;
}

.quick-ranges {
  display: grid;
  gap: 4px;
  border-left: 1px solid var(--line);
  padding-left: 14px;
  align-content: start;
}
.quick-ranges button {
  background: transparent;
  color: var(--ink-2);
  padding: 9px 8px;
  text-align: left;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 8px;
}
.quick-ranges button:hover {
  background: var(--bg-3);
  color: var(--brand-dark);
}

/* ========== 财务徽章 ========== */
.finance-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 68px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  border-radius: 6px;
  white-space: nowrap;
}
.finance-badge.actual { background: var(--green-soft); color: var(--green); }
.finance-badge.learned { background: var(--brand-soft); color: var(--brand-dark); }
.finance-badge.estimated { background: var(--orange-soft); color: var(--orange); }
.finance-badge.ignored { background: var(--bg-3); color: var(--ink-3); }

.ok { background: var(--green-soft); color: var(--green); }
.bad { background: var(--red-soft); color: var(--red); }
.mid { background: var(--orange-soft); color: var(--orange); }

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

/* ========== 图片与模态 ========== */
.competitor-img {
  width: 62px;
  height: 62px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--bg-3);
  border: 1px solid var(--line);
  display: block;
  cursor: zoom-in;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.competitor-img:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 20px rgba(120, 100, 70, 0.15);
}

.image-modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(60, 55, 45, 0.55);
  backdrop-filter: blur(12px);
  z-index: 100;
  padding: 28px;
}
.image-modal.open { display: grid; }
.image-modal img {
  max-width: min(88vw, 820px);
  max-height: 86vh;
  border-radius: 12px;
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg);
}
.image-modal button {
  position: fixed;
  right: 24px;
  top: 22px;
  background: var(--bg-2);
  color: var(--ink-1);
  border: 1px solid var(--line-strong);
  font-weight: 600;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
}
.image-modal button:hover {
  background: var(--red-soft);
  color: var(--red);
  border-color: rgba(196, 123, 108, 0.35);
}

/* ========== 提示说明 ========== */
.notice {
  background: var(--orange-soft);
  border: 1px solid rgba(204, 154, 90, 0.25);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  color: var(--orange);
  font-size: 13px;
  line-height: 1.65;
  font-weight: 500;
}

/* ========== 接口验证状态 ========== */
.api-verify-status {
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  margin: 4px 0 6px;
  white-space: pre-wrap;
}
.api-verify-status.ok {
  background: var(--green-soft);
  border: 1px solid rgba(111, 158, 126, 0.3);
  color: var(--green);
}
.api-verify-status.fail {
  background: var(--red-soft);
  border: 1px solid rgba(196, 123, 108, 0.3);
  color: var(--red);
}

/* ========== 店铺分组管理 ========== */
.store-group-panel {
  margin-top: 16px;
}
.store-group-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}
.store-group-form select[multiple] {
  width: 100%;
  min-height: 120px;
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--ink-1);
  font-size: 13px;
}
.store-group-form select[multiple] option {
  padding: 6px 8px;
  border-radius: 4px;
}
.store-group-form select[multiple] option:checked {
  background: var(--brand-soft) linear-gradient(transparent, transparent);
  color: var(--brand-dark);
  font-weight: 600;
}
.store-group-form .muted {
  color: var(--ink-3);
  font-weight: 500;
  margin-left: 8px;
  font-size: 12px;
}

/* ========== 店铺经营概览控件 ========== */
.store-overview-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.store-overview-controls .inline-select select {
  width: 160px;
}

/* ========== 广告加载提示 ========== */
.ads-fetch-hint {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
  background: var(--brand-soft);
  border: 1px solid rgba(107, 142, 175, 0.25);
  border-radius: 999px;
  padding: 8px 14px;
}
.inline-spinner {
  display: inline-block;
  vertical-align: -2px;
  width: 14px;
  height: 14px;
  margin-right: 4px;
  border: 2px solid var(--brand-ring);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spinner-rotate 0.8s linear infinite;
}
.btn-spinner {
  display: inline-block;
  vertical-align: -2px;
  width: 14px;
  height: 14px;
  margin-right: 6px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spinner-rotate 0.8s linear infinite;
}
@keyframes spinner-rotate {
  to { transform: rotate(360deg); }
}

/* 广告加载覆盖 */
#ads.ads-loading #adChart,
#ads.ads-loading #adRows {
  opacity: 0.5;
  transition: opacity 0.2s ease;
}
#ads.ads-loading .chart-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 42px;
  height: 42px;
  border: 4px solid var(--brand-ring);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spinner-rotate 0.8s linear infinite;
  pointer-events: none;
}

/* ========== 广告产品缩略 ========== */
.ad-product {
  display: grid;
  grid-template-columns: 42px minmax(160px, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 230px;
}
.ad-product img,
.ad-product .ad-product-placeholder {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: var(--bg-3);
}
.ad-product .ad-product-placeholder {
  display: grid;
  place-items: center;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 700;
}

/* ========== 趋势图面板 ========== */
.trend-panel {
  background:
    var(--glow-top),
    linear-gradient(180deg, rgba(107, 142, 175, 0.05), transparent 50%),
    var(--bg-2);
}

/* 趋势图日期筛选器：面板靠右展开 */
.chart-date-picker .date-range-panel { right: 0; }
.chart-date-picker .date-range-button { min-width: 220px; }
/* 联动变暗：未被选中来源的范围按钮降低视觉权重 */
.range-pills button.dim,
.quick-ranges button.dim,
[data-summary-range].dim {
  opacity: 0.45;
  filter: grayscale(0.4);
}

/* ========== 其他小细节 ========== */
h1, h2, h3 { margin: 0; letter-spacing: 0; }
.hint { color: var(--ink-3); line-height: 1.6; font-size: 13px; margin: 8px 0 0; }

.orders-table-wrap {
  max-height: min(640px, calc(100vh - 220px));
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

/* ========== 响应式 ========== */
@media (max-width: 1200px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .split { grid-template-columns: 1fr !important; }
  .import-box { grid-template-columns: 1fr 1fr; }
  .date-range-panel { width: 620px; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  aside {
    position: relative;
    min-height: auto;
    height: auto;
    padding: 20px 16px;
  }
  nav { grid-template-columns: repeat(3, 1fr); }
  .tab { padding: 20px 16px 40px; }
  .topbar { padding: 0 18px; height: 58px; }
  .metrics { grid-template-columns: 1fr; }
  .cols-2 { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .dashboard-brief { flex-direction: column; align-items: flex-start; }
  .import-box { grid-template-columns: 1fr; }
  .date-range-panel {
    position: fixed;
    left: 12px;
    right: 12px;
    top: 120px;
    width: auto;
    grid-template-columns: 1fr;
  }
  .quick-ranges {
    grid-template-columns: repeat(3, 1fr);
    border-left: none;
    border-top: 1px solid var(--line);
    padding: 12px 0 0;
  }
}
@media (max-width: 560px) {
  nav { grid-template-columns: 1fr 1fr; }
}

/* =========================================================
   新增功能对齐优化（不改动后端，仅前端排版修正）
   ========================================================= */

/* ---- 通用：工具栏右侧控件统一容器 ---- */
.toolbar > .chart-controls,
.toolbar > .store-overview-controls,
.toolbar > .cost-scope-pills,
.toolbar > .order-filters {
  align-items: flex-end;
}

/* ---- 图表工具栏：多控件优雅换行 ---- */
.trend-panel .toolbar {
  align-items: flex-end;
  gap: 18px;
}
.chart-controls {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px 14px;
  justify-content: flex-end;
  flex: 1 1 auto;
  min-width: 0;
}
.chart-controls > * {
  margin: 0;
}
.chart-controls .inline-select {
  height: 38px;
}
.chart-controls .inline-select select {
  height: 38px;
  min-width: 150px;
}
.chart-controls .chart-date-picker .date-range-button {
  height: 38px;
  min-width: 200px;
  display: inline-flex;
  align-items: center;
}
.chart-controls .segmented.small {
  height: 38px;
}
.chart-controls .segmented.small button {
  height: 100%;
  padding: 0 14px;
}
.chart-controls .legend {
  padding-left: 4px;
  border-left: 1px solid var(--line);
  margin-left: 4px;
}
.chart-heading {
  flex: 0 0 auto;
  min-width: 240px;
  max-width: 360px;
}

@media (max-width: 1280px) {
  .chart-controls .legend {
    border-left: none;
    padding-left: 0;
    margin-left: 0;
    width: 100%;
    border-top: 1px solid var(--line);
    padding-top: 10px;
  }
}

@media (max-width: 1100px) {
  .trend-panel .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }
  .chart-heading {
    max-width: none;
  }
  .chart-controls {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .chart-controls .inline-select,
  .chart-controls .chart-date-picker,
  .chart-controls .segmented.small {
    width: 100%;
  }
  .chart-controls .inline-select select,
  .chart-controls .chart-date-picker .date-range-button {
    width: 100%;
    min-width: 0;
  }
}

/* ---- 店铺概览：视图/分组选择器对齐 ---- */
.store-overview-panel .toolbar {
  align-items: flex-end;
}
.store-overview-controls {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}
.store-overview-controls .inline-select {
  height: 38px;
}
.store-overview-controls .inline-select select {
  height: 38px;
  width: 160px;
  min-width: 140px;
}

/* ---- 成本总览范围：平台/模式/履约对齐 ---- */
.cost-scope-panel .toolbar {
  align-items: flex-end;
}
.cost-scope-pills {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.cost-scope-pills .inline-select {
  height: 38px;
}
.cost-scope-pills .inline-select select {
  height: 38px;
  width: 150px;
  min-width: 130px;
}

/* ---- 成本表单：cols-3 与动态字段节奏统一 ---- */
#costForm {
  gap: 14px;
}
#costForm .cols-3,
#costForm .cols-2 {
  gap: 12px;
}
.cost-dynamic-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 0;
}
.cost-dynamic-fields:not(:empty) + .cols-2,
.cost-dynamic-fields:not(:empty) {
  padding-top: 0;
}
.cost-fee-hint {
  min-height: 42px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* ---- 费用表导入框：6 元素优雅排列 ---- */
.cost-fee-import-box {
  grid-template-columns: repeat(3, minmax(160px, 1fr)) minmax(240px, 1.4fr) auto auto;
  gap: 14px;
  align-items: end;
}
.cost-fee-import-box label {
  min-width: 0;
}
.cost-fee-import-box input[type="file"] {
  font-size: 12px;
  padding: 9px 10px;
}
.cost-fee-import-box button {
  height: 42px;
}
@media (max-width: 1100px) {
  .cost-fee-import-box {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 640px) {
  .cost-fee-import-box {
    grid-template-columns: 1fr;
  }
}

/* ---- 设置页：API 表单按钮组对齐 ---- */
#apiForm {
  gap: 14px;
}
#apiForm .actions {
  margin-top: 4px;
}
#apiForm .actions button {
  height: 42px;
  padding: 0 18px;
}
.optional-api-fields {
  display: grid;
  gap: 14px;
}
.optional-api-fields[hidden] {
  display: none;
}
.api-verify-status {
  margin: 0;
}

/* ---- 设置页：店铺分组表单对齐 ---- */
.store-group-panel {
  margin-top: 20px;
}
.user-admin-panel {
  margin-top: 20px;
}
.store-group-form {
  display: grid;
  gap: 14px;
  margin-bottom: 20px;
}
.employee-form {
  display: grid;
  gap: 14px;
  margin-bottom: 20px;
}
.store-group-form .cols-3 {
  gap: 12px;
}
.employee-form .cols-3 {
  gap: 12px;
}
.store-group-form .cols-3 label,
.store-group-form > label,
.employee-form .cols-3 label {
  min-width: 0;
}
.store-group-form select[multiple] {
  width: 100%;
  min-height: 130px;
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--ink-1);
  font-size: 13px;
  cursor: pointer;
}
.store-group-form select[multiple] option {
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 2px;
}
.store-group-form select[multiple] option:checked {
  background: var(--brand-soft) linear-gradient(transparent, transparent);
  color: var(--brand-dark);
  font-weight: 600;
}
.store-group-form .muted {
  color: var(--ink-3);
  font-weight: 500;
  margin-left: 8px;
  font-size: 12px;
}
.store-group-form .actions {
  margin-top: 4px;
}
.store-group-form .actions button {
  height: 42px;
  padding: 0 18px;
}
.employee-form .actions button {
  height: 42px;
  padding: 0 18px;
}
.user-admin-panel code {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--bg-3);
  color: var(--ink-1);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

/* ---- 订单筛选：日期 + 店铺 + 刷新按钮高度统一 ---- */
.order-filters {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.order-filters > label {
  min-width: 150px;
}
.order-filters select {
  height: 38px;
  min-width: 180px;
}
.order-filters .date-range-button {
  height: 38px;
  min-width: 220px;
}
.order-filters button#reloadOrders {
  height: 38px;
  padding: 0 16px;
}

/* ---- 广告费用工具栏：店铺选择 + 对比开关 + 分段 ---- */
#ads .panel .toolbar {
  align-items: flex-end;
}
#ads .inline-select {
  height: 38px;
}
#ads .inline-select select {
  height: 38px;
  width: 200px;
}
.ad-filterbar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.ad-filterbar .switch-line,
.ad-filterbar .segmented.small {
  height: 38px;
}
.ad-filterbar .segmented.small button {
  height: 100%;
  padding: 0 14px;
}

/* ---- 通用：所有 inline-select 内 select 统一高度 ---- */
.inline-select select,
.inline-select + select,
label.inline-select > select {
  height: 38px;
}

/* ---- split 两列等高与最小宽度 ---- */
.grid.split {
  grid-template-columns: minmax(380px, 420px) minmax(0, 1fr);
  align-items: start;
  gap: 20px;
}
@media (max-width: 1100px) {
  .grid.split {
    grid-template-columns: 1fr;
  }
}

/* ---- 竞品跟价：表单与统计卡间距 ---- */
#competitors .grid.split .panel form {
  margin-bottom: 16px;
}
#competitors .grid {
  gap: 14px;
}

/* ---- 面板标题统一节奏 ---- */
.panel > h3:not(.toolbar h3) {
  margin-bottom: 16px;
}
.panel > form + .grid,
.panel > form + .table-wrap {
  margin-top: 4px;
}

/* ---- 日期范围面板：避免被 chart-controls 容器裁剪 ---- */
.chart-date-picker {
  position: relative;
  z-index: 20;
}
.chart-date-picker .date-range-panel {
  right: 0;
  top: 44px;
}

/* ---- 表格操作列按钮紧凑 ---- */
.table-wrap td button,
.table-wrap td .row-actions {
  margin: 0;
}
.table-wrap td button.secondary {
  padding: 6px 10px;
  font-size: 12px;
  height: auto;
}

/* ---- 范围联动变暗（保留但柔和化） ---- */
.range-pills button.dim,
.quick-ranges button.dim,
[data-summary-range].dim {
  opacity: 0.5;
  filter: grayscale(0.3);
}

/* ---- 侧边卡片行（替代内联样式） ---- */
.side-card .side-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.side-card .side-card-row + .side-card-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.side-card .side-card-row strong {
  margin: 0;
  font-size: 20px;
}

/* ---- 成本清单上方操作栏 ---- */
.cost-list-actions {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

/* ---- 竞品表单：行内紧凑 ---- */
.inline-form {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

/* ---- API 提示框间距 ---- */
.api-notice {
  margin-top: 16px;
}

/* =========================================================
   商品上架（Listing Wizard）— 覆盖 listing.js 内联深色样式
   使用更高优先级选择器，确保浅色主题统一
   ========================================================= */
.listing-wizard { display: flex; flex-direction: column; gap: 20px; }

/* 步骤导航条 */
.listing-steps {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 16px 18px;
  background:
    radial-gradient(500px 200px at 0% 0%, rgba(107, 142, 175, 0.06), transparent 60%),
    var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.listing-step {
  flex: 1;
  min-width: 150px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-3);
  transition: all 0.2s ease;
}
.listing-step .num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: var(--bg-4);
  color: var(--ink-2);
  font-size: 13px;
  flex-shrink: 0;
}
.listing-step.active {
  color: var(--ink-1);
  border-color: rgba(107, 142, 175, 0.35);
  background: linear-gradient(135deg, rgba(107, 142, 175, 0.14), rgba(123, 160, 135, 0.06));
  box-shadow: 0 2px 10px rgba(107, 142, 175, 0.12);
}
.listing-step.active .num {
  background: linear-gradient(135deg, var(--brand), var(--accent-sage));
  color: #fff;
  box-shadow: 0 2px 8px rgba(107, 142, 175, 0.35);
}
.listing-step.done {
  color: var(--green);
  border-color: rgba(111, 158, 126, 0.35);
  background: var(--green-soft);
}
.listing-step.done .num {
  background: var(--green);
  color: #fff;
}
.listing-step .label { line-height: 1.35; font-weight: 600; }
.listing-step .label small {
  display: block;
  opacity: 0.75;
  font-size: 11px;
  font-weight: 500;
  margin-top: 2px;
}

/* 步骤面板 */
.listing-step-pane { display: none; }
.listing-step-pane.active {
  display: grid;
  gap: 16px;
}
.listing-step-pane .cols-3 {
  align-items: end;
}
.listing-step-pane .cols-3 > label[style*="display:flex"] {
  min-height: 42px;
}
.listing-step-pane .cols-3 > label[style*="display:flex"] button {
  width: 100%;
  height: 42px;
}
.listing-step-pane .actions {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

/* 参考图缩略 */
.listing-thumb-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.listing-thumb {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--bg-3);
  box-shadow: var(--shadow-sm);
}
.listing-thumb img { width: 100%; height: 100%; object-fit: cover; }
.listing-thumb .rm {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(60, 55, 45, 0.7);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background 0.15s ease;
}
.listing-thumb .rm:hover { background: var(--red); }

/* 生成图网格 */
.listing-gen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.listing-gen-cell {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--bg-3);
  box-shadow: var(--shadow-sm);
}
.listing-gen-cell img { width: 100%; height: 100%; object-fit: cover; }
.listing-gen-cell .tag {
  position: absolute;
  left: 6px;
  top: 6px;
  padding: 3px 9px;
  border-radius: 6px;
  background: rgba(60, 55, 45, 0.75);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}
.listing-gen-cell.pending {
  display: grid;
  place-items: center;
  color: var(--ink-3);
  font-size: 12px;
  background: var(--bg-3);
}
.listing-gen-cell.pending::after {
  content: '';
  width: 24px;
  height: 24px;
  border: 2px solid var(--brand-ring);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: listing-spin 0.8s linear infinite;
  margin-bottom: 8px;
}
@keyframes listing-spin { to { transform: rotate(360deg); } }

/* 类目列表 */
.listing-cat-list {
  /* 级联选择器自带边框/背景,这里仅作外层间距容器 */
  max-height: none;
  overflow: visible;
  border: none;
  border-radius: 0;
  background: transparent;
}
.listing-cat-list .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-1);
  transition: background 0.12s ease;
}
.listing-cat-list .row:last-child { border-bottom: none; }
.listing-cat-list .row:hover {
  background: var(--brand-soft);
}
.listing-cat-list .row.selected {
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 600;
  border-left: 3px solid var(--brand);
  padding-left: 13px;
}
.listing-cat-list .row .zh { font-weight: 600; color: var(--ink-1); }
.listing-cat-list .row.selected .zh { color: var(--brand-dark); }
.listing-cat-list .row .orig {
  color: var(--ink-3);
  font-size: 12px;
}

/* 发布日志框 */
.listing-log {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.7;
  background: var(--bg-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  color: var(--ink-2);
}

/* 草稿行 */
.listing-draft-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-1);
}
.listing-draft-row:last-child { border-bottom: none; }
.listing-draft-row.is-selected { background: var(--accent-gold-soft, rgba(234,179,8,0.08)); }
.listing-draft-row .listing-draft-info { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.listing-draft-tools { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.inline-check { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.inline-check input { margin: 0; }

/* 上架状态徽章 */
.listing-status-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  margin-left: 6px; white-space: nowrap;
}
.listing-status-badge.is-draft { background: var(--bg-4); color: var(--ink-3); }
.listing-status-badge.is-pending { background: rgba(59,130,246,0.12); color: #2563eb; }
.listing-status-badge.is-done { background: var(--accent-sage-soft); color: var(--accent-sage); }
.listing-status-badge.is-failed { background: rgba(239,68,68,0.12); color: #dc2626; }

.listing-flow-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
  min-height: 30px;
}
.listing-flow-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.3;
}
.listing-flow-chip small {
  color: var(--ink-3);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.listing-flow-chip.is-ok { border-color: rgba(22,163,74,0.22); background: rgba(22,163,74,0.08); color: #15803d; }
.listing-flow-chip.is-bad { border-color: rgba(220,38,38,0.22); background: rgba(220,38,38,0.08); color: #b91c1c; }
.listing-flow-chip.is-warn { border-color: rgba(217,119,6,0.22); background: rgba(217,119,6,0.08); color: #b45309; }

.listing-pricing-result {
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.45;
}
.listing-pricing-result strong { display: block; color: var(--ink-1); margin-bottom: 2px; }
.listing-pricing-result span { display: inline-block; margin-right: 10px; white-space: nowrap; }
.listing-pricing-result.is-error {
  border-color: rgba(220,38,38,0.22);
  background: rgba(220,38,38,0.08);
  color: #b91c1c;
}

/* 动态属性表单 */
.listing-divider { border: none; border-top: 1px solid var(--line); margin: 18px 0; }
.listing-attrs-wrap { margin-bottom: 8px; }
.listing-attrs-primary {
  border: 1px solid rgba(107, 142, 175, 0.28);
  border-radius: var(--radius-sm);
  background: rgba(107, 142, 175, 0.06);
  padding: 14px;
}
.listing-attrs-primary .toolbar {
  align-items: flex-start;
}
.listing-attr-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px;
}
.listing-attr-row .listing-attr-name { min-width: 140px; max-width: 200px; color: var(--ink-2); flex-shrink: 0; }
.listing-attr-row.is-required .listing-attr-name { font-weight: 600; color: var(--ink-1); }
.listing-attr-row input, .listing-attr-row select { flex: 1; }
.listing-attr-filter {
  flex: 0 0 160px;
  min-width: 120px;
}
.listing-param-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.listing-import-box {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 14px;
  background: #fff;
}
.listing-import-box .toolbar {
  align-items: flex-start;
}
.listing-import-cost {
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--soft);
  font-weight: 600;
  color: var(--ink-1);
}
.listing-param-rows {
  display: grid;
  gap: 8px;
}
.listing-param-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.7fr) minmax(180px, 1.3fr) auto;
  gap: 8px;
  align-items: center;
}
.listing-param-row input {
  min-width: 0;
}
.listing-param-row button {
  min-height: 34px;
  padding: 6px 12px;
}
.listing-variant-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.listing-variant-box .toolbar { align-items: flex-start; }
.listing-variant-table .table-wrap { max-height: 420px; }
.listing-variant-table table { min-width: 920px; }
.listing-variant-table input {
  min-width: 96px;
  height: 32px;
  padding: 6px 8px;
  font-size: 12px;
}
.listing-variant-table td,
.listing-variant-table th {
  white-space: nowrap;
}
.listing-draft-tools .primary,
.listing-draft-tools .secondary,
.listing-draft-tools .danger {
  min-height: 32px;
  padding: 6px 12px;
  font-size: 12px;
}

/* 全局加载遮罩(转圈圈) */
.global-loader {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(250, 248, 243, 0.55);
  backdrop-filter: blur(2px);
}
.global-loader[hidden] { display: none; }
.global-loader-card {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 28px 40px;
  background: #fdfbf6; border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 12px 36px rgba(60, 50, 40, 0.12);
}
.global-spinner {
  width: 38px; height: 38px;
  border: 3.5px solid rgba(120, 110, 90, 0.15);
  border-top-color: #6b8eaf;
  border-radius: 50%;
  animation: globalSpin 0.85s linear infinite;
}
.global-loader-text { color: var(--ink-2); font-size: 14px; }
@keyframes globalSpin { to { transform: rotate(360deg); } }

/* 数据分析 tab */
.analytics-filter-bar { flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.analytics-filter-bar label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); }
.analytics-filter-bar select, .analytics-filter-bar input { min-width: 180px; }
.analytics-table { width: 100%; border-collapse: collapse; }
.analytics-table th, .analytics-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; }
.analytics-table th { background: rgba(120, 110, 90, 0.06); color: var(--ink-2); font-weight: 600; }
.analytics-table td.money { font-variant-numeric: tabular-nums; }
.analytics-table .sku { font-size: 12px; color: var(--ink-3); max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#analyticsSummary .metric { min-width: 0; }
#analyticsSummary .metric strong { font-size: 20px; }
.listing-step-pane .search { margin-top: 4px; }
.listing-step-pane .table-status { margin: 0; }

/* ========== 商品上架:三级级联类目选择器 ========== */
.listing-cascade {
  display: flex;
  gap: 0;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-2);
  overflow: hidden;
}
.listing-cascade-col {
  flex: 1 1 0;
  min-width: 0;
  border-right: 1px solid var(--line);
  background: var(--bg-2);
  display: flex;
  flex-direction: column;
}
.listing-cascade-col:last-child { border-right: none; }
.listing-cascade-col-title {
  padding: 8px 14px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  background: var(--bg-3);
  border-bottom: 1px solid var(--line);
  text-transform: uppercase;
}
.listing-cascade-col-body {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  /* 关键:列表在列内滚动,不让整个页面变长 */
  max-height: 360px;
}
.listing-cascade-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-2);
  transition: all 0.15s ease;
  user-select: none;
}
.listing-cascade-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.listing-cascade-item .arrow { color: var(--ink-4); font-size: 12px; flex-shrink: 0; }
.listing-cascade-item .leaf-tag {
  font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: var(--accent-sage-soft); color: var(--accent-sage); flex-shrink: 0;
}
.listing-cascade-item:hover { background: var(--bg-3); color: var(--ink-1); }
.listing-cascade-item.has-child:hover .arrow { color: var(--brand); }
.listing-cascade-item.selected {
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 700;
}
.listing-cascade-item.selected .arrow { color: var(--brand-dark); }
.listing-cascade-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--bg-1);
}
.listing-cascade-breadcrumb {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--ink-2);
}
.listing-cascade-breadcrumb strong { color: var(--brand-dark); font-weight: 700; }
@media (max-width: 720px) {
  .listing-cascade { flex-direction: column; min-height: 0; }
  .listing-cascade-col { border-right: none; border-bottom: 1px solid var(--line); max-height: 220px; }
  .listing-cascade-col:last-child { border-bottom: none; }
}

/* 类目搜索框 + 下拉结果 */
.listing-cat-search { position: relative; margin-bottom: 4px; }
.listing-cat-search .search { width: 100%; }
.listing-cat-search-result {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 50;
  max-height: 340px;
  overflow-y: auto;
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
}
.listing-search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-2);
  transition: background 0.12s ease;
}
.listing-search-item:hover { background: var(--bg-3); color: var(--ink-1); }
.listing-search-item .path { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.listing-search-item mark { background: var(--accent-gold); color: #fff; padding: 0 3px; border-radius: 3px; }
.listing-search-item .leaf-tag,
.listing-search-item .level-tag {
  font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px; flex-shrink: 0;
}
.listing-search-item .leaf-tag { background: var(--accent-sage-soft); color: var(--accent-sage); }
.listing-search-item .level-tag { background: var(--bg-4); color: var(--ink-3); }
.listing-search-empty {
  padding: 16px; text-align: center; color: var(--ink-3); font-size: 12.5px;
}

/* =========================================================
   货盘管理（Sourcing Tray）— 表单与清单排版优化
   ========================================================= */
#sourcing .dashboard-brief { margin-bottom: 4px; }

#sourcingForm {
  gap: 14px;
}
#sourcingForm .cols-2,
#sourcingForm .cols-3 {
  gap: 12px;
  align-items: end;
}
/* 必填星标 */
#sourcingForm label small { color: var(--red); font-weight: 700; }

/* 货盘清单上方操作栏：与成本清单统一节奏 */
#sourcing .panel .toolbar + .actions {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
#sourcing .panel .toolbar + .actions button {
  height: 38px;
  padding: 0 16px;
}

/* 货盘清单表格：操作列紧凑、文字列对齐 */
#sourcingRows td { vertical-align: middle; }
#sourcingRows td.actions,
#sourcingRows td .actions {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
}
#sourcingRows td.actions button,
#sourcingRows .actions button {
  padding: 6px 10px;
  font-size: 12px;
  height: auto;
  min-height: 30px;
}
#sourcingRows td a {
  color: var(--brand-dark);
  text-decoration: none;
  font-weight: 600;
  font-size: 12.5px;
}
#sourcingRows td a:hover { text-decoration: underline; }

/* 货盘提示文字（导入说明）更柔和 */
#sourcingImportStatus {
  padding: 10px 12px;
  background: var(--bg-3);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--brand);
}

/* =========================================================
   OZON 活动报名（Promotions）
   ========================================================= */
.promo-control-panel .toolbar {
  align-items: flex-start;
  gap: 16px;
}

.promo-controls,
.promo-bulkbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
}

.promo-controls .inline-select,
.promo-bulkbar .inline-select {
  min-width: 150px;
}

.promo-controls select,
.promo-bulkbar input,
.promo-price-input,
.promo-stock-input {
  min-height: 38px;
}

.promo-controls #promoAction {
  min-width: min(360px, 52vw);
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  color: var(--ink-2);
  font-weight: 700;
}

.inline-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

.promo-grid {
  align-items: start;
}

.promo-actions-wrap {
  max-height: 520px;
}

.promo-products-wrap {
  max-height: 640px;
}

.promo-actions-wrap tbody tr,
.promo-products-wrap tbody tr {
  transition: background 0.15s ease;
}

.promo-action-active {
  background: var(--brand-soft);
}

.promo-price-input,
.promo-stock-input {
  width: 112px;
  max-width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--ink-1);
  font: inherit;
}

.promo-stock-input {
  width: 86px;
}

.promo-products-wrap th:first-child,
.promo-products-wrap td:first-child {
  width: 42px;
  text-align: center;
}

.promo-product {
  display: grid;
  grid-template-columns: 46px minmax(160px, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.promo-product-copy {
  min-width: 0;
}

.promo-product-name {
  display: -webkit-box;
  max-height: 42px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.promo-product .sku {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.promo-product-img,
.promo-product-placeholder {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--bg-2);
  border: 1px solid var(--line);
}

.promo-product-placeholder {
  display: grid;
  place-items: center;
  color: var(--ink-3);
  font-weight: 800;
  font-size: 12px;
}

/* 响应式：货盘与上架在窄屏时表单堆叠 */
@media (max-width: 900px) {
  .listing-step {
    min-width: 100%;
  }
  .listing-steps {
    flex-direction: column;
  }
  #sourcingForm .cols-3 {
    grid-template-columns: 1fr;
  }
  .promo-controls,
  .promo-bulkbar {
    align-items: stretch;
  }
  .promo-controls > *,
  .promo-bulkbar > * {
    flex: 1 1 160px;
  }
  .promo-controls #promoAction {
    min-width: 100%;
  }
}

/* =========================================================
   AI 生图 / 文本工作室（AI Studio）
   ========================================================= */
#aiStudio .dashboard-brief { margin-bottom: 4px; }

/* 第一步：上传 + 信息输入区 */
.ai-studio-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 22px;
}
@media (max-width: 900px) {
  .ai-studio-input { grid-template-columns: 1fr; }
}

/* 拖拽上传区 */
.ai-studio-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 36px 20px;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-1);
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: center;
}
.ai-studio-dropzone:hover,
.ai-studio-dropzone.is-drag {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.ai-studio-dropzone .ai-dropzone-icon { font-size: 34px; line-height: 1; }
.ai-studio-dropzone .ai-dropzone-text { font-size: 14px; font-weight: 600; color: var(--ink-1); }
.ai-studio-dropzone .ai-dropzone-hint { font-size: 12px; color: var(--ink-3); }

/* 参考图缩略图 */
.ai-thumb-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  min-height: 32px;
}
.ai-thumb-empty {
  width: 100%;
  padding: 10px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-3);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
}
.ai-thumb {
  position: relative;
  width: 88px;
  height: 110px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg-2);
  box-shadow: var(--shadow-sm);
}
.ai-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ai-thumb-badge {
  position: absolute; top: 4px; left: 4px;
  font-size: 10px; font-weight: 700; color: #fff;
  background: rgba(107, 142, 175, 0.85);
  padding: 2px 6px; border-radius: 999px;
}
.ai-thumb .rm {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px; line-height: 18px;
  border: none; border-radius: 50%;
  background: rgba(60, 50, 40, 0.6); color: #fff;
  font-size: 14px; cursor: pointer; padding: 0;
  transition: background 0.15s ease;
}
.ai-thumb .rm:hover { background: var(--red); }

/* 右侧字段区 */
.ai-studio-fields { display: flex; flex-direction: column; gap: 14px; }
.ai-studio-fields textarea { min-height: 96px; resize: vertical; }
.ai-studio-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.ai-studio-actions .primary { flex: 1 1 auto; min-width: 200px; }

/* 第二步：提示词展示区（Tab + 提示词文本块） */
.ai-prompt-tabs {
  display: flex;
  gap: 0;
  margin-top: 6px;
  border-bottom: 1px solid var(--line);
}
.ai-prompt-tab {
  appearance: none;
  border: none;
  background: transparent;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.ai-prompt-tab:hover { color: var(--ink-1); }
.ai-prompt-tab.active {
  color: var(--brand-dark);
  border-bottom-color: var(--brand);
}
.ai-prompt-pane { display: none; padding-top: 14px; }
.ai-prompt-pane.active { display: block; }

/* 单个提示词块（标题栏 + 正文 pre） */
.ai-prompt-block {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-2);
  overflow: hidden;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.ai-prompt-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 14px;
  background: var(--bg-3);
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.ai-prompt-block-head .ai-prompt-role-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 11.5px;
  font-weight: 700;
}
.ai-prompt-block-head button {
  flex-shrink: 0;
  padding: 5px 14px;
  font-size: 12px;
  min-height: 28px;
  height: auto;
}
.ai-prompt-text {
  margin: 0;
  padding: 14px 16px;
  font-family: "SF Mono", "Consolas", "Menlo", monospace;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--ink-1);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 520px;
  overflow-y: auto;
  background: var(--bg-2);
}

/* 第二步：同款链接抓取 */
.ai-similar-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 8px;
}
.ai-similar-row input[type="url"] {
  flex: 1;
  min-width: 0;
}
.ai-similar-row .primary {
  flex-shrink: 0;
  white-space: nowrap;
  padding: 0 18px;
  min-height: 38px;
}

/* 同款结果卡片 */
.ai-similar-card {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-2);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.ai-similar-meta {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-3);
}
.ai-similar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-1);
  margin-bottom: 6px;
  line-height: 1.4;
}
.ai-similar-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.ai-similar-specs {
  font-size: 12.5px;
  color: var(--ink-2);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.ai-similar-specs strong { color: var(--ink-1); margin-right: 4px; }
.ai-similar-highlights {
  padding: 12px 16px;
}
.ai-similar-highlights > strong {
  display: block;
  font-size: 12.5px;
  color: var(--brand-dark);
  margin-bottom: 6px;
}
.ai-similar-highlights ul {
  margin: 0;
  padding-left: 18px;
  list-style: disc;
}
.ai-similar-highlights li {
  font-size: 13px;
  color: var(--ink-1);
  line-height: 1.7;
  padding-left: 2px;
}

/* 通用 ai-tag 标签胶囊 */
.ai-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

/* 历史列表 */
.ai-history-empty {
  padding: 24px;
  text-align: center;
  font-size: 13px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-1);
}
.ai-history-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 6px;
  border-bottom: 1px solid var(--line);
}
.ai-history-row:last-child { border-bottom: none; }
.ai-history-cover {
  width: 52px; height: 64px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  border: 1px solid var(--line);
}
.ai-history-cover img { width: 100%; height: 100%; object-fit: cover; }
.ai-history-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ai-history-info strong { font-size: 13.5px; color: var(--ink-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-history-info small { font-size: 11.5px; color: var(--ink-3); }
.ai-history-actions { display: flex; gap: 6px; flex-shrink: 0; }
.ai-history-actions button { padding: 5px 10px; font-size: 12px; min-height: 28px; height: auto; }

body.auth-locked {
  overflow: hidden;
}

body.auth-locked .app {
  filter: blur(2px);
  pointer-events: none;
  user-select: none;
}

.login-gate {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(250, 248, 243, 0.88);
  backdrop-filter: blur(10px);
}

.login-gate[hidden],
.auth-user-box[hidden] {
  display: none !important;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  border-radius: var(--radius-md);
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg);
}

.login-card h2 {
  margin: 0 0 4px;
  font-size: 22px;
  color: var(--ink-1);
}

.login-kicker {
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.login-card label {
  display: grid;
  gap: 7px;
  color: var(--ink-2);
  font-weight: 700;
}

.login-card input {
  width: 100%;
}

.password-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 8px;
}

.password-field input {
  min-width: 0;
}

.password-toggle {
  min-width: 58px;
  padding: 0 12px;
  background: var(--bg-3);
  color: var(--ink-2);
  border: 1px solid var(--line-strong);
  font-size: 12px;
}

.password-toggle:hover {
  background: var(--bg-4);
  color: var(--ink-1);
}

.login-card button {
  min-height: 42px;
}

.login-status {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--red-soft);
  color: var(--red);
  font-weight: 700;
  line-height: 1.5;
}

.login-status.ok {
  background: var(--green-soft);
  color: var(--green);
}

.auth-user-box {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.auth-user-box > span:first-child {
  color: var(--ink-2);
  font-weight: 700;
}

.auth-user-box button {
  height: 34px;
  padding: 0 12px;
}

/* =========================================================
   多主题配色（通过顶栏「🎨 配色」切换，选择保存在浏览器本地）
   默认主题：暖米护眼（无需 data-theme）
   ========================================================= */

/* 雾蓝清爽 — 冷调浅蓝灰 */
[data-theme="ocean"] {
  --bg-0: #e7eef5;
  --bg-1: #f3f7fa;
  --bg-2: #ffffff;
  --bg-3: #e9f1f7;
  --bg-4: #dce7f0;
  --line: rgba(80, 100, 125, 0.14);
  --line-strong: rgba(80, 100, 125, 0.26);
  --ink-1: #2f3a45;
  --ink-2: #55636f;
  --ink-3: #7e8c97;
  --ink-4: #a8b4bd;
  --brand: #4a86c5;
  --brand-dark: #3568a3;
  --brand-soft: rgba(74, 134, 197, 0.12);
  --brand-ring: rgba(74, 134, 197, 0.3);
  --accent-sage: #4f9d8f;
  --accent-sage-soft: rgba(79, 157, 143, 0.14);
  --accent-clay: #c98a5e;
  --accent-gold: #d9a844;
  --green: #4f9d7a;
  --green-soft: rgba(79, 157, 122, 0.14);
  --red: #cd6f62;
  --red-soft: rgba(205, 111, 98, 0.12);
  --orange: #d19a4e;
  --orange-soft: rgba(209, 154, 78, 0.14);
  --shadow-sm: 0 2px 8px rgba(60, 90, 120, 0.07);
  --shadow-md: 0 8px 24px rgba(60, 90, 120, 0.09);
  --shadow-lg: 0 20px 50px rgba(60, 90, 120, 0.13);
  --glow-top: linear-gradient(180deg, rgba(245, 250, 255, 0.7), transparent 50%);
}

/* 森林墨绿 — 深绿点缀 + 青灰底 */
[data-theme="forest"] {
  --bg-0: #e9efe9;
  --bg-1: #f4f7f2;
  --bg-2: #ffffff;
  --bg-3: #eaf1e6;
  --bg-4: #dce6d6;
  --line: rgba(70, 95, 75, 0.13);
  --line-strong: rgba(70, 95, 75, 0.24);
  --ink-1: #31402f;
  --ink-2: #55644f;
  --ink-3: #7f8c78;
  --ink-4: #aab4a3;
  --brand: #4e8a5a;
  --brand-dark: #3a6d46;
  --brand-soft: rgba(78, 138, 90, 0.12);
  --brand-ring: rgba(78, 138, 90, 0.28);
  --accent-sage: #6f9fb0;
  --accent-sage-soft: rgba(111, 159, 176, 0.14);
  --accent-clay: #c08a5f;
  --accent-gold: #c9a24a;
  --green: #4e9463;
  --green-soft: rgba(78, 148, 99, 0.14);
  --red: #c4705f;
  --red-soft: rgba(196, 112, 95, 0.12);
  --orange: #cd9a52;
  --orange-soft: rgba(205, 154, 82, 0.14);
  --shadow-sm: 0 2px 8px rgba(60, 90, 60, 0.06);
  --shadow-md: 0 8px 24px rgba(60, 90, 60, 0.08);
  --shadow-lg: 0 20px 50px rgba(60, 90, 60, 0.12);
  --glow-top: linear-gradient(180deg, rgba(250, 255, 248, 0.7), transparent 50%);
}

/* 紫藤夜色（浅紫） — 柔和紫调 */
[data-theme="violet"] {
  --bg-0: #efecf5;
  --bg-1: #f7f5fa;
  --bg-2: #ffffff;
  --bg-3: #f0ecf6;
  --bg-4: #e4deee;
  --line: rgba(95, 85, 120, 0.13);
  --line-strong: rgba(95, 85, 120, 0.24);
  --ink-1: #3b3648;
  --ink-2: #615b70;
  --ink-3: #888199;
  --ink-4: #b0aabd;
  --brand: #8a72c4;
  --brand-dark: #6e57a8;
  --brand-soft: rgba(138, 114, 196, 0.12);
  --brand-ring: rgba(138, 114, 196, 0.3);
  --accent-sage: #6fa08e;
  --accent-sage-soft: rgba(111, 160, 142, 0.14);
  --accent-clay: #c98a76;
  --accent-gold: #cda852;
  --green: #6f9e7e;
  --green-soft: rgba(111, 158, 126, 0.14);
  --red: #c97a70;
  --red-soft: rgba(201, 122, 112, 0.12);
  --orange: #cf9c58;
  --orange-soft: rgba(207, 156, 88, 0.14);
  --shadow-sm: 0 2px 8px rgba(90, 75, 130, 0.07);
  --shadow-md: 0 8px 24px rgba(90, 75, 130, 0.09);
  --shadow-lg: 0 20px 50px rgba(90, 75, 130, 0.13);
  --glow-top: linear-gradient(180deg, rgba(252, 250, 255, 0.7), transparent 50%);
}

/* 暗夜深色 — 深蓝灰底 + 雾蓝点缀 */
[data-theme="night"] {
  --bg-0: #161b24;
  --bg-1: #1c2330;
  --bg-2: #242d3d;
  --bg-3: #2a3547;
  --bg-4: #323e52;
  --line: rgba(160, 180, 210, 0.14);
  --line-strong: rgba(160, 180, 210, 0.26);
  --ink-1: #e8edf5;
  --ink-2: #b6c1d1;
  --ink-3: #8b98ab;
  --ink-4: #66738a;
  --brand: #6d9fd8;
  --brand-dark: #8ab4e4;
  --brand-soft: rgba(109, 159, 216, 0.18);
  --brand-ring: rgba(109, 159, 216, 0.4);
  --accent-sage: #7cb797;
  --accent-sage-soft: rgba(124, 183, 151, 0.18);
  --accent-clay: #d0977f;
  --accent-gold: #d8b365;
  --green: #7ab78f;
  --green-soft: rgba(122, 183, 143, 0.18);
  --red: #d98a7c;
  --red-soft: rgba(217, 138, 124, 0.16);
  --orange: #d9ab6b;
  --orange-soft: rgba(217, 171, 107, 0.18);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.36);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.44);
  --glow-top: linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 50%);
}

/* 暗夜下的细节补偿：图片与图表区域保持可读 */
[data-theme="night"] img { filter: brightness(0.92); }
[data-theme="night"] .promo-product-placeholder { color: var(--ink-1); }

/* ============ 配色选择器 ============ */
.theme-picker { position: relative; display: inline-flex; align-items: center; }
.theme-picker-btn { height: 34px; padding: 0 12px; white-space: nowrap; }
.theme-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  min-width: 220px;
  padding: 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  display: grid;
  gap: 4px;
}
.theme-panel[hidden] { display: none; }
.theme-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-1);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  box-shadow: none;
}
.theme-choice:hover { background: var(--bg-3); transform: none; box-shadow: none; }
.theme-choice.active { border-color: var(--brand-ring); background: var(--brand-soft); }
.theme-choice .swatches { display: inline-flex; gap: 3px; }
.theme-choice .swatches i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.12);
  display: inline-block;
}
.topbar h2 { margin-right: auto; }

/* 各主题顶栏半透明底色 */
[data-theme="ocean"] { --topbar-a: rgba(243, 247, 250, 0.9); --topbar-b: rgba(243, 247, 250, 0.7); }
[data-theme="forest"] { --topbar-a: rgba(244, 247, 242, 0.9); --topbar-b: rgba(244, 247, 242, 0.7); }
[data-theme="violet"] { --topbar-a: rgba(247, 245, 250, 0.9); --topbar-b: rgba(247, 245, 250, 0.7); }
[data-theme="night"] { --topbar-a: rgba(28, 35, 48, 0.92); --topbar-b: rgba(28, 35, 48, 0.75); }
