/* Ozon Seller 控制台样式：双主题（深色 / 亮色）、克制、数据优先 */

/* ---------- 主题变量 ---------- */

:root,
:root[data-theme="dark"] {
  --bg: #0f1218;
  --bg-soft: #151a22;
  --panel: #1a2029;
  --panel-2: #212936;
  --line: #2a3342;
  --line-strong: #38445a;
  --text: #e6ebf2;
  --text-dim: #97a3b6;
  --text-faint: #6b7787;
  --accent: #005bff;
  --accent-hover: #1a6bff;
  --accent-soft: rgba(0, 91, 255, 0.14);
  --accent-text: #8fb4ff;
  --ok: #22b07d;
  --ok-text: #79dfb6;
  --ok-soft: rgba(34, 176, 125, 0.1);
  --ok-line: rgba(34, 176, 125, 0.45);
  --warn: #e2a33c;
  --warn-text: #f0c778;
  --warn-soft: rgba(226, 163, 60, 0.1);
  --warn-line: rgba(226, 163, 60, 0.45);
  --bad: #e2554f;
  --bad-text: #ff9b96;
  --bad-soft: rgba(226, 85, 79, 0.1);
  --bad-line: rgba(226, 85, 79, 0.5);
  --topbar-bg: rgba(15, 18, 24, 0.92);
  --row-hover: rgba(255, 255, 255, 0.02);
  --row-line: rgba(42, 51, 66, 0.6);
  --spin-track: rgba(255, 255, 255, 0.35);
  --spin-head: #fff;
  --bar-from: #3d7dff;
  --bar-to: #005bff;
  --shadow: none;
  --scrim: rgba(6, 9, 14, 0.62);
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Code", Consolas, monospace;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f4f6fa;
  --bg-soft: #ffffff;
  --panel: #ffffff;
  --panel-2: #eef2f8;
  --line: #e1e7f0;
  --line-strong: #c8d2e1;
  --text: #16202e;
  --text-dim: #4a5768;
  --text-faint: #7b8798;
  --accent: #005bff;
  --accent-hover: #0049cc;
  --accent-soft: rgba(0, 91, 255, 0.08);
  --accent-text: #0049cc;
  --ok: #12915f;
  --ok-text: #0b7048;
  --ok-soft: rgba(18, 145, 95, 0.1);
  --ok-line: rgba(18, 145, 95, 0.35);
  --warn: #b8790f;
  --warn-text: #90600a;
  --warn-soft: rgba(184, 121, 15, 0.1);
  --warn-line: rgba(184, 121, 15, 0.35);
  --bad: #d0433d;
  --bad-text: #b02c27;
  --bad-soft: rgba(208, 67, 61, 0.09);
  --bad-line: rgba(208, 67, 61, 0.35);
  --topbar-bg: rgba(255, 255, 255, 0.9);
  --row-hover: rgba(16, 32, 56, 0.03);
  --row-line: rgba(225, 231, 240, 0.9);
  --spin-track: rgba(255, 255, 255, 0.45);
  --spin-head: #fff;
  --bar-from: #7ba3ff;
  --bar-to: #005bff;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 10px 26px rgba(16, 24, 40, 0.06);
  --scrim: rgba(22, 32, 46, 0.34);
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Code", Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  transition: background 0.2s ease, color 0.2s ease;
}

body {
  display: grid;
  grid-template-columns: 214px 1fr;
  min-height: 100vh;
}

/* ---------- 侧栏 ---------- */

.sidebar {
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  display: grid;
  place-items: center;
  letter-spacing: 0.5px;
  flex: 0 0 auto;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text small { color: var(--text-faint); font-size: 11px; }

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav a {
  color: var(--text-dim);
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
}

.nav a:hover { background: var(--panel-2); color: var(--text); }

.nav a.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  box-shadow: inset 2px 0 0 var(--accent);
}

.sidebar-foot {
  margin-top: auto;
  padding: 12px 10px 4px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-dim);
}

.status-line { display: flex; align-items: center; gap: 7px; }

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
  flex: 0 0 auto;
}

.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }

.tiny { font-size: 11px; color: var(--text-faint); margin-top: 6px; word-break: break-all; }

.user-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 11.5px;
  color: var(--text-faint);
}

.user-line strong { color: var(--text-dim); font-weight: 600; }

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent-text);
  font-size: 11.5px;
  cursor: pointer;
  font-family: inherit;
}

.link-btn:hover { text-decoration: underline; }

/* ---------- 主区 ---------- */

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 28px 16px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--topbar-bg);
  backdrop-filter: blur(6px);
  z-index: 5;
}

.topbar h1 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: 0.2px; }
.topbar .sub { margin: 4px 0 0; color: var(--text-faint); font-size: 12.5px; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn:hover { background: var(--panel-2); border-color: var(--line-strong); }
.btn:disabled { opacity: 0.55; cursor: default; }

.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }

.btn.ghost { background: transparent; }

.btn.sm { padding: 4px 10px; font-size: 12px; border-radius: 7px; }

.btn.danger { border-color: var(--bad-line); color: var(--bad-text); background: var(--bad-soft); }
.btn.danger:hover { background: var(--bad); color: #fff; border-color: var(--bad); }

.icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
}

.spin {
  width: 12px;
  height: 12px;
  border: 2px solid var(--spin-track);
  border-top-color: var(--spin-head);
  border-radius: 50%;
  display: none;
  animation: spin 0.7s linear infinite;
}

.btn.loading .spin { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.content { padding: 22px 28px 48px; }

/* ---------- 卡片与网格 ---------- */

.grid { display: grid; gap: 14px; }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.card h2,
.card h3 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.kpi-card { display: flex; flex-direction: column; gap: 6px; }
.kpi-label { font-size: 12.5px; color: var(--text-faint); }
.kpi-value { font-size: 24px; font-weight: 650; letter-spacing: 0.3px; font-variant-numeric: tabular-nums; }
.kpi-hint { font-size: 11.5px; color: var(--text-faint); }

/* ---------- 表格 ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

thead th {
  text-align: left;
  padding: 10px 14px;
  background: var(--panel-2);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--row-line);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--row-hover); }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.mono { font-family: var(--mono); font-size: 12px; color: var(--text-dim); }
td.actions { white-space: nowrap; text-align: right; }

/* ---------- 徽章 / 标签 ---------- */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  border: 1px solid var(--line);
  color: var(--text-dim);
  white-space: nowrap;
}
.badge.ok { color: var(--ok-text); border-color: var(--ok-line); background: var(--ok-soft); }
.badge.warn { color: var(--warn-text); border-color: var(--warn-line); background: var(--warn-soft); }
.badge.bad { color: var(--bad-text); border-color: var(--bad-line); background: var(--bad-soft); }
.badge.dim { color: var(--text-faint); }

.delta.up { color: var(--ok); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--text-faint); }

/* ---------- 价格指数分布条 ---------- */

.zones { display: flex; flex-direction: column; gap: 10px; }

.zone-row { display: grid; grid-template-columns: 92px 1fr 64px; align-items: center; gap: 12px; font-size: 12.5px; }
.zone-bar { height: 8px; border-radius: 999px; background: var(--panel-2); overflow: hidden; }
.zone-fill { height: 100%; border-radius: 999px; }
.zone-fill.green { background: #22b07d; }
.zone-fill.yellow { background: #e2a33c; }
.zone-fill.red { background: #e2554f; }
.zone-fill.super { background: #7a63ff; }
.zone-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-dim); }

/* ---------- 键值列表 ---------- */

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 10px 16px; font-size: 13px; }
.kv dt { color: var(--text-faint); }
.kv dd { margin: 0; word-break: break-word; }

/* ---------- 工具条 ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 12.5px;
  color: var(--text-dim);
}

.toolbar label { display: inline-flex; align-items: center; gap: 6px; }

.toolbar input[type="date"],
.toolbar input[type="number"],
.toolbar select,
.toolbar input[type="text"] {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 7px;
  padding: 6px 9px;
  font-size: 12.5px;
  font-family: inherit;
}

.spacer { flex: 1; }

/* ---------- 商品缩略图 ---------- */

.thumb {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.cell-name { display: flex; gap: 10px; align-items: center; min-width: 260px; }
.cell-name .name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- 提示 / 空态 ---------- */

.alert {
  margin: 16px 28px 0;
  padding: 11px 14px;
  border-radius: 8px;
  border: 1px solid var(--bad-line);
  background: var(--bad-soft);
  color: var(--bad-text);
  font-size: 13px;
}

.alert.info { border-color: var(--warn-line); background: var(--warn-soft); color: var(--warn-text); }
.alert.ok { border-color: var(--ok-line); background: var(--ok-soft); color: var(--ok-text); }

.hidden { display: none !important; }

.empty, .skeleton {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}

.muted { color: var(--text-faint); }
.small { font-size: 12px; }
.sec-title { margin: 26px 0 12px; font-size: 14px; font-weight: 600; }
.sec-title:first-child { margin-top: 0; }

.chart { display: flex; align-items: flex-end; gap: 8px; height: 130px; padding: 8px 4px 0; }
.chart .bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; }
.chart .bar { width: 100%; max-width: 46px; background: linear-gradient(180deg, var(--bar-from), var(--bar-to)); border-radius: 4px 4px 0 0; min-height: 2px; }
.chart .bar-label { font-size: 10.5px; color: var(--text-faint); white-space: nowrap; }

.footer-note { margin-top: 18px; font-size: 11.5px; color: var(--text-faint); }

/* ---------- 趋势图 ---------- */

.trend-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 8px; box-shadow: var(--shadow); }
.trend-box h2 { margin: 0 0 4px; font-size: 13px; font-weight: 600; color: var(--text-dim); letter-spacing: 0.4px; text-transform: uppercase; }
.trend-meta { font-size: 11.5px; color: var(--text-faint); margin-bottom: 8px; }
.trend-svg { width: 100%; height: 150px; display: block; }
.trend-svg .grid-line { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.trend-svg .axis-label { fill: var(--text-faint); font-size: 9.5px; }
.trend-svg .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trend-svg .area { fill: var(--accent); opacity: 0.1; }
.trend-svg .point { fill: var(--panel); stroke: var(--accent); stroke-width: 1.5; }

.kpi-trend { display: flex; flex-direction: column; gap: 4px; }
.diff { font-size: 12px; font-variant-numeric: tabular-nums; }
.diff.up { color: var(--ok); }
.diff.down { color: var(--bad); }
.diff.flat { color: var(--text-faint); }

/* ---------- 模态框 ---------- */

.scrim {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
  backdrop-filter: blur(2px);
}

.modal {
  width: min(560px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 48px rgba(8, 12, 20, 0.35);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 10px;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 { margin: 0; font-size: 15px; }
.modal-head .sub { margin: 4px 0 0; font-size: 12px; color: var(--text-faint); }
.modal-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--line);
}

.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--text-dim); }
.field span { color: var(--text-faint); }

.field input,
.field select {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13px;
  font-family: inherit;
  width: 100%;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.check { display: flex; align-items: flex-start; gap: 8px; font-size: 12.5px; color: var(--text-dim); line-height: 1.5; }
.check input { margin-top: 2px; }

.notice {
  border: 1px solid var(--warn-line);
  background: var(--warn-soft);
  color: var(--warn-text);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 12px;
}

.notice.ok { border-color: var(--ok-line); background: var(--ok-soft); color: var(--ok-text); }
.notice.bad { border-color: var(--bad-line); background: var(--bad-soft); color: var(--bad-text); }

.preview-list { max-height: 180px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; }
.preview-list div { padding: 6px 10px; border-bottom: 1px solid var(--row-line); font-family: var(--mono); }
.preview-list div:last-child { border-bottom: none; }

/* ---------- 登录页 ---------- */

.login-body { display: block; background: var(--bg); }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 26px 26px 20px;
  box-shadow: 0 16px 44px rgba(8, 12, 20, 0.16);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.login-brand strong { display: block; font-size: 15px; }
.login-brand small { color: var(--text-faint); font-size: 12px; }

#login-form { display: flex; flex-direction: column; gap: 14px; }

.login-submit { justify-content: center; padding: 10px 14px; font-size: 14px; }

.login-error {
  margin-top: 2px;
  border: 1px solid var(--bad-line);
  background: var(--bad-soft);
  color: var(--bad-text);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 12.5px;
}

.login-foot { margin: 16px 0 0; font-size: 11.5px; color: var(--text-faint); line-height: 1.6; }

/* ---------- 响应式 ---------- */

@media (max-width: 820px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: column; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
  .alert { margin-left: 16px; margin-right: 16px; }
  .field-row { grid-template-columns: 1fr; }
}

/* ---------- 写操作模态框（改价 / 改库存） ---------- */

body.modal-open { overflow: hidden; }

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--scrim);
}

.modal {
  width: min(600px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: 0 24px 60px rgba(4, 10, 22, 0.32);
  padding: 20px 22px 18px;
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.modal-head h2 {
  flex: 1;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.modal-sub {
  margin: 0 0 14px;
  color: var(--text-dim);
  font-size: 12.5px;
  word-break: break-all;
}

.modal-body {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 5px;
}

.field-label {
  font-size: 12.5px;
  color: var(--text-dim);
}

.field-label .req { color: var(--bad); font-style: normal; }

.field input,
.field select {
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-hint {
  font-size: 11.5px;
  color: var(--text-faint);
}

.modal-preview {
  margin-top: 14px;
  padding: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 12.5px;
}

.preview-ok {
  color: var(--ok-text);
  font-weight: 600;
  margin-bottom: 8px;
}

.preview-bad {
  color: var(--bad-text);
  font-weight: 600;
}

.kv-box {
  display: grid;
  gap: 4px;
  margin-bottom: 8px;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px dashed var(--row-line);
  padding-bottom: 3px;
}

.warn-list {
  margin: 6px 0;
  padding: 8px 10px;
  color: var(--warn-text);
  background: var(--warn-soft);
  border-left: 2px solid var(--warn-line);
  border-radius: 6px;
}

.confirm-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--warn-text);
  background: var(--warn-soft);
  border: 1px solid var(--warn-line);
  border-radius: var(--radius);
  cursor: pointer;
}

.confirm-check input { margin-top: 2px; accent-color: var(--accent); }

.modal-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

.modal-foot .btn { min-width: 88px; justify-content: center; }

/* ---------- 表格里的动作按钮 ---------- */

td.actions { text-align: right; white-space: nowrap; }
td.actions .btn.sm { padding: 3px 9px; font-size: 12px; }

@media (max-width: 720px) {
  .modal { padding: 16px; }
  .modal-foot { flex-wrap: wrap; }
  .modal-foot .btn { flex: 1; }
}
