/* ============================================================================
   OZON 后台 · 统一视觉主题层 (theme.css)
   单一来源，零 !important。替代 shell.css 中 v3/v4/v5 三层叠加补丁。
   设计语言：冷调蓝白 · 大圆角 · 柔和阴影 · 等宽数字 · 清晰层级
   ========================================================================== */

/* ---------- 1. 设计令牌 ---------- */
/* 选择器与 shell.css 的 html:root 同等具体，靠加载顺序取胜（theme.css 在后） */
html:root,
html body {
  /* 品牌色 —— 对齐 Ozon 财务分析平台 */
  --brand: #005bff;
  --brand-600: #0049cc;
  --brand-700: #134b9b;
  --brand-50: #eef4ff;
  --brand-100: #dbe8ff;

  /* 语义色 */
  --ok: #13875b;      --ok-l: #e6f6ef;
  --warn: #b97900;    --warn-l: #fdf6e6;
  --err: #c63e3e;     --err-l: #fdeeee;
  --info: #134b9b;    --info-l: #eef4ff;

  /* 中性色阶 */
  --ink: #152238;     --ink-2: #24344d;
  --txt: #152238;
  --sub: #6e7c91;
  --muted: #8b98aa;
  --line: #e3e9f1;
  --line-2: #eef2f7;
  --paper: #f4f7fb;
  --bg: #f4f7fb;
  --card: #ffffff;
  --panel: #ffffff;

  /* 圆角：严格三档 */
  --r-card: 14px;     /* 卡片/面板 */
  --r-ctl: 8px;       /* 控件/按钮 */
  --r-pill: 20px;     /* 胶囊 */

  /* 阴影：蓝调柔和（参考站同款） */
  --shadow-card: 0 8px 26px rgba(24,55,92,.07);
  --shadow-pop: 0 12px 36px rgba(24,55,92,.14);

  /* 间距节奏 */
  --gap: 14px;
  --pad-card: 20px;

  /* 字号 */
  --fs-xs: 12px;
  --fs-sm: 12.5px;
  --fs-base: 13.5px;
  --fs-lg: 15px;
  --fs-xl: 22px;

  /* 侧边栏：深海军蓝 */
  --app-sb-w: 232px;
  --sb-bg: #0d2f62;
  --sb-fg: #b9cce7;
  --sb-fg-on: #ffffff;
  --sb-hover: rgba(255,255,255,.08);
  --sb-active: rgba(255,255,255,.14);
}

/* 兼容旧页面变量名（各页 :root 已移除，这里兜底旧变量名） */
html:root,
html body {
  --acc: var(--brand);
  --line2: var(--line-2);
  --radius: var(--r-card);
  --shadow: var(--shadow-card);
  --text: var(--txt);
  --gray: var(--sub);
}

/* ---------- 2. 基准 ---------- */
html body {
  background: var(--paper);
  color: var(--txt);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
               "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: var(--fs-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* 等宽数字：全站表格与数字统一对齐 */
.num, .kpi .v, .money, td.r, th.r,
table td, table tfoot td { font-variant-numeric: tabular-nums; }

h1 { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -.4px; color: var(--ink); }
h2 { font-size: var(--fs-lg); font-weight: 600; letter-spacing: -.2px; color: var(--ink); }
h3 { font-size: var(--fs-base); font-weight: 600; color: var(--ink-2); }
a  { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 3. 顶部栏：渐变而非纯白 ---------- */
header.top, header.sticky, header.top-app {
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(15,23,42,.02);
}
header.top h1, header.sticky h1 {
  font-size: 15px; font-weight: 700; letter-spacing: -.2px;
}

/* ---------- 4. 卡片 ---------- */
.card, .panel, .board-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  padding: var(--pad-card);
}
.card h2, .card h3 {
  font-size: var(--fs-base); font-weight: 600; letter-spacing: -.2px;
  margin: 0 0 14px; color: var(--ink); display: flex; align-items: center;
  justify-content: space-between; gap: 10px;
}

/* ---------- 5. KPI：标签 12px 灰 + 数字 25px（参考站规格） ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 14px; }
.kpi {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: transform .18s, box-shadow .18s;
}
.kpi::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--brand);
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-pop); }
.kpi .k, .kpi .lab, .kpi small {
  display: block; font-size: 12px; color: var(--sub);
  font-weight: 500; line-height: 1.4;
}
.kpi .v, .kpi strong {
  display: block;
  font-size: 25px; font-weight: 700; letter-spacing: -.6px;
  color: var(--ink); line-height: 1.2;
  margin: 10px 0 4px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.kpi .u, .kpi .sub { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 3px; }

/* ---------- 6. 表格：对齐参考站（#f5f7fa 表头 / 12.5px / 行悬停 #fafcff） ---------- */
.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--panel);
  overflow: auto;
  box-shadow: var(--shadow-card);
}
table:not(.board) {
  width: 100%; border-collapse: collapse;
  font-size: 12.5px;
}
table:not(.board) thead th {
  position: sticky; top: 0; z-index: 2;
  background: #f5f7fa;
  color: #627086;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  text-align: left;
  padding: 11px 13px;
  border: 0;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  vertical-align: middle;
}
table:not(.board) tbody td {
  font-size: 12.5px;
  color: var(--ink-2);
  padding: 12px 13px;
  border: 0;
  border-top: 1px solid var(--line);
  white-space: nowrap;
  vertical-align: middle;
}
table:not(.board) tbody tr:hover td { background: #fafcff; }
table:not(.board) tbody tr:last-child td { border-bottom: 0; }
table:not(.board) tfoot td {
  background: #f5f7fa;
  font-size: 12.5px; font-weight: 700;
  padding: 12px 13px;
  border: 0; border-top: 1px solid var(--line);
  color: var(--ink);
}
table:not(.board) td.r, table:not(.board) th.r,
table:not(.board) td.num, table:not(.board) th.num { text-align: right; }
table:not(.board) td small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
table:not(.board) .neg, table:not(.board) td.neg { color: var(--err); }

/* ---------- 7. 表单控件 ---------- */
input:not([type=checkbox]):not([type=radio]):not([type=file]),
select, textarea {
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  background: #fff;
  color: var(--txt);
  font-size: var(--fs-sm);
  font-family: inherit;
  padding: 8px 11px;
  min-height: 36px;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
input:hover:not(:focus), select:hover:not(:focus) { border-color: #cbd5e1; }
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
  outline: none;
}
input[readonly] { background: var(--paper); color: var(--sub); cursor: default; }
.f label { font-size: var(--fs-xs); color: var(--sub); font-weight: 500; margin-bottom: 3px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 14px; }

/* ---------- 8. 按钮 ---------- */
button, .btn {
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  background: #fff;
  color: var(--ink-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  font-family: inherit;
  padding: 8px 14px;
  min-height: 36px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  touch-action: manipulation;
}
button:hover, .btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: var(--ink);
}
button.pri, button.primary, button.btn-primary, .btn-brand {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 1px 2px rgba(37,99,235,.24);
}
button.pri:hover, button.primary:hover, button.btn-primary:hover {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: #fff;
}
button.danger { color: var(--err); border-color: #fecaca; }
button.danger:hover { background: var(--err-l); border-color: var(--err); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
button:focus-visible, a:focus-visible {
  outline: 2px solid rgba(37,99,235,.4);
  outline-offset: 2px;
}
.acts { display: flex; gap: 6px; }
.acts button { padding: 4px 10px; min-height: 28px; font-size: var(--fs-xs); }

/* ---------- 9. 徽标 / 状态 ---------- */
.badge, .tag, .pill, .status {
  display: inline-block;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  line-height: 1.6;
}
.badge      { background: var(--brand-50); color: var(--brand-700); }
.tag.auto   { background: var(--brand-50); color: var(--brand-700); }
.tag.man    { background: var(--warn-l); color: #b45309; }
.pill.up    { background: var(--ok-l); color: var(--ok); }
.pill.down  { background: var(--err-l); color: var(--err); }
.pill.flat  { background: var(--line-2); color: var(--muted); }

/* ---------- 10. 汇总条 / 空态 / 提示 ---------- */
.pv {
  display: flex; gap: 20px; align-items: baseline; flex-wrap: wrap;
  border-top: 1px dashed var(--line);
  margin-top: 12px; padding-top: 10px;
  font-size: var(--fs-xs); color: var(--sub);
}
.pv b { font-size: 15px; color: var(--ink); font-weight: 700; }
.empty { padding: 32px; text-align: center; color: var(--muted); font-size: var(--fs-sm); }
.hint, .sub, small { font-size: var(--fs-xs); color: var(--muted); }
.msg { font-size: var(--fs-xs); min-height: 16px; }
.msg.err { color: var(--err); }
.msg.ok  { color: var(--ok); }
.code { font-weight: 600; color: var(--brand); }

/* ---------- 11. 滚动条 ---------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb {
  background: #dbe2ea; border-radius: 6px; border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: #c3cdd9; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 12. 深色模式（变量级，一次写对） ---------- */
html.oz-dark,
html.oz-dark body {
  --brand: #4d7cff;      --brand-600: #3b63e0;  --brand-700: #93b4ff;
  --brand-50: #16233d;   --brand-100: #1e2f4d;
  --ok: #34d399;         --ok-l: #06281d;
  --warn: #fbbf24;       --warn-l: #2a1f06;
  --err: #f87171;        --err-l: #2d1214;
  --ink: #e6edf7;        --ink-2: #c8d4e5;
  --txt: #e6edf7;
  --sub: #93a4bd;
  --muted: #7b8ca6;
  --line: #26324a;       --line-2: #1c2536;
  --paper: #0e1626;
  --bg: #0e1626;
  --card: #152033;
  --shadow-card: 0 1px 2px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.24);
  background: var(--paper);
  color: var(--txt);
}
html.oz-dark body .card,
html.oz-dark body .panel,
html.oz-dark body .table-wrap { background: var(--card); border-color: var(--line); }
html.oz-dark body header.top,
html.oz-dark body header.sticky,
html.oz-dark body header.top-app {
  background: linear-gradient(180deg, #141e30 0%, #111a29 100%);
  border-bottom-color: var(--line);
}
html.oz-dark body .kpi {
  background: linear-gradient(180deg, #18243a 0%, #152033 100%);
  border-color: var(--line);
}
html.oz-dark body .kpi .v { color: var(--ink); }
html.oz-dark body table:not(.board) thead th {
  background: linear-gradient(180deg, #1a2540 0%, #16203a 100%);
  color: var(--sub);
  border-bottom-color: var(--line);
}
html.oz-dark body table:not(.board) tbody td { color: var(--ink-2); border-bottom-color: var(--line-2); }
html.oz-dark body table:not(.board) tbody tr:nth-child(even) td { background: #172234; }
html.oz-dark body table:not(.board) tbody tr:hover td { background: #1c2c47; }
html.oz-dark body table:not(.board) tfoot td { background: #18243a; border-top-color: var(--line); }
html.oz-dark body input:not([type=checkbox]):not([type=radio]):not([type=file]),
html.oz-dark body select,
html.oz-dark body textarea {
  background: #111a29; border-color: var(--line); color: var(--txt);
}
html.oz-dark body button:not(.pri):not(.primary) {
  background: #1a2540; border-color: var(--line); color: var(--ink-2);
}
html.oz-dark body button:not(.pri):not(.primary):hover { background: #22304e; color: var(--ink); }
html.oz-dark body .pv { border-top-color: var(--line); }
html.oz-dark body ::-webkit-scrollbar-thumb { background: #2c3a55; background-clip: padding-box; }
/* 系统深色偏好 */
@media (prefers-color-scheme: dark) {
  html.oz-auto-dark,
  html.oz-auto-dark body {
    --brand: #4d7cff;  --brand-600: #3b63e0;  --brand-700: #93b4ff;
    --brand-50: #16233d; --brand-100: #1e2f4d;
    --ok: #34d399;  --ok-l: #06281d;
    --warn: #fbbf24; --warn-l: #2a1f06;
    --err: #f87171;  --err-l: #2d1214;
    --ink: #e6edf7;  --ink-2: #c8d4e5;  --txt: #e6edf7;
    --sub: #93a4bd;  --muted: #7b8ca6;
    --line: #26324a; --line-2: #1c2536;
    --paper: #0e1626; --bg: #0e1626; --card: #152033;
    background: var(--paper); color: var(--txt);
  }
}

/* ---------- 13. 移动端 ---------- */
@media (max-width: 900px) {
  :root { --pad-card: 14px 14px; --gap: 10px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: 1fr; }
  table:not(.board) thead th,
  table:not(.board) tbody td { padding: 9px 10px; }
}
@media (max-width: 640px) {
  .kpis { grid-template-columns: 1fr; }
  .kpi .v { font-size: 20px; }
  input:not([type=checkbox]):not([type=radio]),
  select, textarea, button { font-size: 16px; min-height: 42px; }
}

/* ---------- 14. 打印 ---------- */
@media print {
  #appShell, header.top, header.sticky, #ozToastWrap, .app-mask { display: none !important; }
  body { background: #fff; }
  .card, .table-wrap { box-shadow: none; border-color: #ddd; break-inside: avoid; }
  table:not(.board) thead th { position: static; }
}
