/* 网页后台：Apple 风格，苹方字体，跟随系统深浅色 */
:root {
  color-scheme: light dark;
  --bg: #f5f5f7;
  --card: #ffffff;
  --card-2: #f2f2f4;
  --line: #e3e3e8;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #8e8e93;
  --blue: #0071e3;
  --blue-soft: rgba(0, 113, 227, 0.1);
  --red: #d70015;
  --orange: #b25000;
  --green: #1a7f37;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --card-2: #2c2c2e;
    --line: #38383a;
    --text: #f5f5f7;
    --text-2: #aeaeb2;
    --text-3: #8e8e93;
    --blue: #2997ff;
    --blue-soft: rgba(41, 151, 255, 0.16);
    --red: #ff6961;
    --orange: #ffb340;
    --green: #4cd964;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.hidden { display: none !important; }

.btn { height: 30px; padding: 0 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--card); white-space: nowrap; }
.btn:hover { background: var(--card-2); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 500; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.link { border: 0; background: none; color: var(--blue); padding: 0 4px; height: auto; }
.input { height: 30px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--card); }

/* 登录 */
.login { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.login form { width: 100%; max-width: 340px; background: var(--card); border-radius: 14px; padding: 28px; }
.login h1 { font-size: 24px; margin: 0 0 4px; font-weight: 600; }
.login p { margin: 0 0 20px; color: var(--text-2); }
.login label { display: block; margin-bottom: 12px; color: var(--text-2); }
.login .input { display: block; width: 100%; height: 38px; margin-top: 4px; color: var(--text); }
.login .btn { width: 100%; height: 38px; margin-top: 8px; }
.login .err { min-height: 18px; margin: 10px 0 0; color: var(--red); }
.foot { padding: 16px; text-align: center; color: var(--text-3); font-size: 12px; }
.foot a { color: inherit; }

/* 框架 */
.shell { height: 100%; display: grid; grid-template-rows: 48px auto auto 1fr; }
.top { display: flex; align-items: center; gap: 16px; padding: 0 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.top b { font-size: 15px; font-weight: 600; }
.top .shop { color: var(--text-2); }
.top .me { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--text-2); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.kpi { background: var(--card); padding: 10px 16px; }
.kpi span { display: block; color: var(--text-2); font-size: 12px; }
.kpi b { display: block; margin-top: 1px; font-size: 20px; font-weight: 600; }
.kpi b.warn { color: var(--orange); }

.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 16px; }
.seg { display: inline-flex; padding: 2px; background: var(--card-2); border-radius: 8px; }
.seg button { height: 26px; padding: 0 12px; border: 0; border-radius: 6px; background: none; }
.seg button.on { background: var(--card); font-weight: 500; box-shadow: 0 0 0 .5px var(--line); }
.search { width: 260px; max-width: 100%; }
.bar .spacer { flex: 1; }

.body { min-height: 0; display: grid; grid-template-columns: 216px minmax(0, 1fr); gap: 0 12px; padding: 0 16px 12px; }

/* 左边筛选 */
.filters { min-height: 0; overflow: auto; background: var(--card); border-radius: 10px; padding: 4px 0 8px; }
.fhead { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px 2px; }
.fhead b { font-size: 12px; color: var(--text-2); font-weight: 500; }
.opt { display: flex; align-items: center; gap: 6px; width: 100%; padding: 3px 12px; cursor: pointer; }
.opt:hover { background: var(--card-2); }
.opt input { margin: 0; flex: none; accent-color: var(--blue); }
.opt span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.opt em { font-style: normal; color: var(--text-3); font-variant-numeric: tabular-nums; }
.opt.sub { padding-left: 34px; }
.opt .tw { flex: none; width: 16px; height: 16px; padding: 0; border: 0; background: none; color: var(--text-3); line-height: 16px; }

/* 表格 */
.panel { min-height: 0; display: flex; flex-direction: column; background: var(--card); border-radius: 10px; overflow: hidden; }
.batch { display: flex; align-items: center; gap: 8px; padding: 7px 12px; background: var(--blue-soft); }
.scroll { flex: 1; min-height: 0; overflow: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th { position: sticky; top: 0; z-index: 1; height: 32px; padding: 0 10px; background: var(--card); border-bottom: 1px solid var(--line); color: var(--text-2); font-size: 12px; font-weight: 500; text-align: left; white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th.sorted { color: var(--blue); }
td { height: 44px; padding: 3px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: var(--card-2); }
tbody tr.on td { background: var(--blue-soft); }
th.r, td.r { text-align: right; }
.check { width: 34px; padding-right: 0; }
.check input { accent-color: var(--blue); display: block; }
.pic { width: 44px; padding-right: 0; }
.opt.inline { width: auto; padding: 3px 4px; }
.thumb { display: block; width: 32px; height: 32px; object-fit: cover; border-radius: 5px; background: var(--card-2); }
.mdl { font-weight: 500; }
.sub { color: var(--text-2); font-size: 12px; }
.price-sale { color: var(--blue); font-weight: 600; }
.warn { color: var(--orange); }
.bad { color: var(--red); }
.good { color: var(--green); }
.price-btn { min-width: 64px; padding: 2px 6px; margin-right: -6px; border: 0; border-radius: 5px; background: none; text-align: right; }
.price-btn:hover:not(:disabled) { background: var(--blue-soft); }
.price-btn:disabled { cursor: default; }
.price-edit { width: 76px; height: 26px; padding: 0 6px; border: 1px solid var(--blue); border-radius: 5px; background: var(--card); text-align: right; }
.empty { padding: 56px 16px; text-align: center; color: var(--text-2); }
.pager { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-top: 1px solid var(--line); color: var(--text-2); }
.pager .spacer { flex: 1; }
.pager select { height: 26px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); }
.pager .btn { height: 26px; }

/* 右边详情 */
.mask { position: fixed; inset: 0; z-index: 10; background: rgba(0, 0, 0, .25); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 11; width: 420px; max-width: 100%; overflow: auto; background: var(--bg); box-shadow: -8px 0 30px rgba(0, 0, 0, .18); }
.dhead { position: sticky; top: 0; z-index: 1; display: flex; align-items: flex-start; gap: 8px; padding: 14px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.dhead h2 { flex: 1; margin: 0; font-size: 16px; font-weight: 600; }
.photos { display: flex; gap: 6px; overflow-x: auto; padding: 12px 16px 0; }
.photos a { flex: none; }
.photos img { display: block; width: 96px; height: 124px; object-fit: cover; border-radius: 8px; background: var(--card-2); }
.group { margin: 12px 16px; background: var(--card); border-radius: 10px; overflow: hidden; }
.group h3 { margin: 0; padding: 9px 12px 3px; color: var(--text-2); font-size: 12px; font-weight: 500; }
.row { display: flex; gap: 16px; justify-content: space-between; padding: 7px 12px; border-top: 1px solid var(--line); }
.group h3 + .row { border-top: 0; }
.row span:first-child { flex: none; color: var(--text-2); }
.row span:last-child { text-align: right; overflow-wrap: anywhere; }

/* 弹框 */
dialog { width: 360px; max-width: calc(100% - 32px); padding: 20px; border: 0; border-radius: 14px; background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, .3); }
dialog h2 { margin: 0 0 12px; font-size: 16px; font-weight: 600; }
dialog label { display: block; margin-bottom: 10px; color: var(--text-2); }
dialog .input { display: block; width: 100%; margin-top: 4px; color: var(--text); }
dialog .acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
dialog .preview { max-height: 180px; overflow: auto; margin: 0; padding: 8px 10px; background: var(--card-2); border-radius: 8px; }
dialog .preview div { display: flex; justify-content: space-between; gap: 12px; padding: 1px 0; }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 30; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 8px 16px; border-radius: 9px; background: rgba(30, 30, 32, .94); color: #fff; }
.toast.err { background: var(--red); color: #fff; }

@media (max-width: 860px) {
  .shell { height: auto; display: block; }
  .body { display: block; }
  .filters { margin-bottom: 12px; max-height: 240px; }
  .scroll { max-height: 70vh; }
  .search { width: 100%; }
}
