/* ============ Ozon 数据看板 · UI Refresh 2026-09-12 ============
   独立覆盖层：只调整视觉与排版，不改变业务逻辑。
   保留原设计系统的主题变量、表格吸顶和无横向滚动规则。
*/
:root {
  --ui-font: "Segoe UI Variable Text", "Segoe UI", "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  --ui-mono: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --ui-radius: 12px;
  --ui-shadow: 0 1px 2px rgba(15, 23, 42, .035), 0 8px 22px rgba(15, 23, 42, .055);
  --ui-shadow-strong: 0 18px 48px rgba(8, 18, 34, .18);
}

html { background: var(--bg); }
body {
  font-family: var(--ui-font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: rgba(0, 91, 255, .18); }
button, input, select, textarea { font-family: inherit; }
:focus-visible { outline: 3px solid rgba(0, 91, 255, .24); outline-offset: 2px; }

/* 顶栏 */
.topbar {
  padding: 12px 22px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, .035);
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  box-shadow: 0 8px 18px rgba(0, 91, 255, .25);
}
.brand-text h1 { font-size: 17px; font-weight: 760; letter-spacing: .015em; }
.brand-sub { margin-top: 2px; font-size: 11.5px; letter-spacing: .02em; }
.top-actions { gap: 9px; }
.sync-info { line-height: 1.55; }

/* 侧栏 */
.sidebar {
  width: 196px;
  padding: 16px 10px 14px;
  box-shadow: 10px 0 30px rgba(8, 18, 34, .06);
}
.sidebar li {
  position: relative;
  margin: 3px 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 600;
  letter-spacing: .01em;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}
.sidebar li:hover { transform: translateX(1px); }
.sidebar li.active {
  background: var(--nav-active);
  box-shadow: 0 8px 18px rgba(0, 91, 255, .22);
}
.nav-ic { width: 20px; font-size: 14px; opacity: .94; }
.sidebar-foot { padding: 10px 12px; line-height: 1.6; }

/* 工作区 */
.main { padding: 22px 26px 36px; }
.page-filter-bar {
  padding: 12px 14px;
  margin-bottom: 18px;
  border-radius: var(--ui-radius);
  box-shadow: var(--ui-shadow);
}
.page-filter-label { font-weight: 650; }
.ctrl { font-weight: 600; }

/* KPI：六张卡片改为三列，金额不再被挤成三行 */
.kpi-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.kpi {
  position: relative;
  min-width: 0;
  overflow: hidden;
  padding: 16px 18px 16px 22px;
  border-radius: var(--ui-radius);
  box-shadow: var(--ui-shadow);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.kpi::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--accent);
}
.kpi:nth-child(3)::before { background: var(--danger); }
.kpi:nth-child(4)::before { background: var(--accent2); }
.kpi:nth-child(5)::before { background: #7C3AED; }
.kpi:nth-child(6)::before { background: var(--danger); }
.kpi:hover { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(15, 23, 42, .08); }
.kpi .k-label { font-size: 12.5px; font-weight: 700; letter-spacing: .015em; }
.kpi .k-value {
  margin-top: 7px;
  font-family: var(--ui-mono);
  font-size: 26px;
  font-weight: 760;
  line-height: 1.17;
  letter-spacing: -.035em;
  overflow-wrap: normal;
  word-break: normal;
}
.kpi .k-sub { margin-top: 7px; font-size: 11.5px; line-height: 1.6; }

/* 面板 */
.panel {
  padding: 18px 20px;
  border-radius: var(--ui-radius);
  box-shadow: var(--ui-shadow);
}
.panel h3 {
  gap: 9px;
  margin-bottom: 14px;
  font-size: 15px;
  font-weight: 740;
  letter-spacing: .005em;
}
.panel h3::before {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  box-shadow: 0 0 0 4px rgba(0, 91, 255, .09);
}
.chart { min-height: 260px; }

/* 表格：继续只处理外层 table-scroll，嵌套表格不处理 */
table { font-size: 13.5px; }
th {
  padding: 11px 12px;
  background: var(--surface2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .02em;
}
td { padding: 11px 12px; border-bottom: 1px solid var(--border); }
tbody tr:nth-child(even) { background: var(--surface2); }
tbody tr:hover { background: rgba(0, 91, 255, .075); }
.num { font-family: var(--ui-mono); }
.table-scroll {
  max-height: 70vh;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.table-scroll > table { margin: 0; }
.table-scroll > table > thead > tr > th,
.table-scroll > table > tr:first-child > th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface2);
  box-shadow: inset 0 -1px 0 var(--border);
}
.table-scroll > table > tbody > tr > td { vertical-align: middle; }
.row-detail td { background: var(--surface2); }

/* 控件 */
.btn {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 14px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.25;
  white-space: nowrap;
  transition: border-color .15s ease, background .15s ease, color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.btn:hover { filter: none; box-shadow: 0 6px 14px rgba(0, 91, 255, .14); transform: translateY(-1px); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn.ghost {
  background: var(--surface);
  border: 1px solid var(--border);
}
.btn.danger { box-shadow: 0 6px 14px rgba(229, 72, 77, .15); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.sm { min-height: 28px; padding: 4px 9px; border-radius: 8px; font-size: 12px; }
.icon-btn { width: 34px; height: 34px; border-radius: 9px; }
.select, .input, .search-input, .login-select {
  border-radius: 9px;
  background: var(--surface2);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.select:focus, .input:focus, .search-input:focus, .login-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 91, 255, .11);
}
.seg { padding: 2px; border-radius: 9px; }
.seg-btn { border-radius: 7px; font-weight: 600; }
.seg-btn.active { box-shadow: 0 3px 8px rgba(0, 91, 255, .2); }

/* 状态与辅助信息 */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  padding: 3px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
  line-height: 1.3;
  white-space: nowrap;
}
.empty { padding: 28px 0; font-size: 13px; }
.toast { border-radius: 10px; box-shadow: var(--ui-shadow-strong); }

/* 登录页 */
.login-page {
  background:
    radial-gradient(circle at 75% 18%, rgba(0, 91, 255, .22), transparent 34%),
    radial-gradient(circle at 12% 85%, rgba(0, 169, 143, .10), transparent 28%),
    linear-gradient(145deg, #091523 0%, #10233B 58%, #0C3F9B 150%);
}
.login-box {
  border-top: 4px solid var(--accent);
  border-radius: 18px;
  padding: 34px 32px 32px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .32);
}
.login-brand h1 { font-size: 22px; font-weight: 760; letter-spacing: -.015em; }
.login-brand p { margin-top: 7px; font-size: 12.5px; }
.login-tip { line-height: 1.75; }

/* 主题细节 */
[data-theme="dark"] .topbar { box-shadow: 0 1px 0 rgba(255, 255, 255, .035); }
[data-theme="dark"] .kpi:hover { box-shadow: 0 12px 28px rgba(0, 0, 0, .28); }
[data-theme="dark"] .sidebar { box-shadow: 10px 0 30px rgba(0, 0, 0, .16); }
[data-theme="dark"] .btn.ghost { background: var(--surface); }

/* 自适应 */
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  .main { padding: 16px; }
  .kpi-grid { gap: 12px; }
  .kpi { padding: 15px 16px 15px 20px; }
}
@media (max-width: 768px) {
  .topbar { padding: 9px 11px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi .k-value { font-size: 19px; }
  .panel { padding: 14px; border-radius: 11px; }
  .panel h3 { font-size: 14px; }
}
@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi .k-value { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
/* 订单表：商品名称和渠道过长时省略，悬停查看完整内容；其他列不处理 */
.orders-table .cell-channel,
.orders-table .cell-product-name { max-width: 180px; }
.orders-table .ellipsis-text {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: help;
}
.orders-table .cell-channel .ellipsis-text { max-width: 120px; }
.orders-table .cell-product-name .ellipsis-text { max-width: 180px; }
@media (max-width: 1280px) {
  .orders-table .cell-channel .ellipsis-text { max-width: 105px; }
  .orders-table .cell-product-name .ellipsis-text { max-width: 150px; }
}

/* 订单表紧凑模式：关键编号保持一行，名称/渠道继续省略 */
.orders-table { font-size: 13px; }
.orders-table th,
.orders-table td { padding: 9px 8px; }
.orders-table .cell-store,
.orders-table .cell-tracking,
.orders-table .cell-date,
.orders-table .cell-offer,
.orders-table .cell-sku,
.orders-table .cell-posting,
.orders-table .cell-status { white-space: nowrap; }
.orders-table .cell-status,
.orders-table .cell-channel { padding-left: 5px; padding-right: 5px; }
.orders-table .cell-channel .ellipsis-text { max-width: 110px; }
.orders-table .cell-product-name .ellipsis-text { max-width: 155px; }
@media (max-width: 1280px) {
  .orders-table .cell-channel .ellipsis-text { max-width: 96px; }
  .orders-table .cell-product-name .ellipsis-text { max-width: 135px; }
}

/* 手机端订单表：改为纵向卡片，避免横向裁切 */
@media (max-width: 768px) {
  .topbar { padding: 8px 10px; }
  .main { padding: 10px; }
  .sidebar { width: 230px; }
  .page-filter-bar { padding: 9px 10px; margin-bottom: 12px; }
  .orders-panel { overflow-x: visible !important; padding: 10px; }
  .orders-table { display: block; width: 100%; font-size: 13px; }
  .orders-table > thead { display: none; }
  .orders-table > tbody { display: block; width: 100%; }
  .orders-table > tbody > tr:not(.row-detail) {
    display: block;
    width: 100%;
    margin: 0 0 10px;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 11px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .045);
  }
  .orders-table > tbody > tr:not(.row-detail) > td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 10px;
    width: 100%;
    padding: 5px 0;
    border: 0;
    text-align: left;
    white-space: normal !important;
    overflow: visible;
  }
  .orders-table > tbody > tr:not(.row-detail) > td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.7;
  }
  .orders-table .cell-channel,
  .orders-table .cell-product-name { max-width: none; }
  .orders-table .cell-channel .ellipsis-text,
  .orders-table .cell-product-name .ellipsis-text {
    display: -webkit-box;
    max-width: none;
    overflow: hidden;
    white-space: normal;
    text-overflow: clip;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    cursor: help;
  }
  .orders-table > tbody > tr:not(.row-detail) > td.row-arrow { display: none; }
  .orders-table > tbody > tr.row-detail { display: block; margin: -4px 0 12px; }
  .orders-table > tbody > tr.row-detail > td {
    display: block;
    padding: 0 0 10px;
    border: 0;
    white-space: normal;
    overflow: visible;
  }
  .orders-table > tbody > tr.row-detail .fin-table { display: table; width: 100%; font-size: 12px; }
  .orders-table > tbody > tr.row-detail .fin-table th,
  .orders-table > tbody > tr.row-detail .fin-table td { padding: 6px 7px; }
}
