/* Management console layout */
.admin-layout {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 100vh;
}
.admin-sidebar {
  background: linear-gradient(180deg, #0f172a, #111827);
  color: #cbd5e1;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.admin-sidebar .brand {
  display: block;
  padding: 18px 20px;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.admin-sidebar .brand small { display: block; font-size: 11px; font-weight: 400; color: #94a3b8; margin-top: 2px; }
.admin-nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.admin-nav a {
  display: block;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: #cbd5e1;
  font-size: 13px;
  transition: background .12s, color .12s;
}
/* display: block above also overrides the browser's [hidden] rule. */
.admin-nav a[hidden] { display: none; }
.admin-nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.admin-nav a.active { background: var(--primary); color: #fff; font-weight: 600; box-shadow: 0 4px 14px rgba(47, 111, 237, .35); }
.admin-nav .group { padding: 14px 12px 6px; font-size: 11px; color: #64748b; }

.admin-main { min-width: 0; display: flex; flex-direction: column; }
.admin-topbar {
  height: 60px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.admin-topbar .title { font-weight: 600; letter-spacing: -.01em; }
.admin-user { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.admin-content { padding: 24px; }

.admin-content .card { margin-top: 0; }
.filter-bar { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar .field { margin-bottom: 0; min-width: 140px; }
.filter-bar .field.grow { flex: 1 1 200px; }
/* 勾选类筛选项：与同一行的 .input/.select（min-height 42px）底部对齐 */
.filter-bar .field > label.check-line {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 42px; font-size: 13px; font-weight: 500; color: var(--text);
  cursor: pointer;
}
.filter-bar .check-line input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); cursor: pointer; }

/* 商品列表批量操作条：未选中时按钮 disabled，提示文字留在左侧 */
.bulk-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.bulk-bar .muted { font-size: 13px; }
.bulk-bar input[type="checkbox"],
.table th.check-col input,
.table td.check-col input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); cursor: pointer; }
.table th.check-col, .table td.check-col { width: 36px; padding-right: 0; }

/* 商品列表的「数量范围」列也做原地编辑，外观与售价的 .cell-edit 一致；
   区间用 nowrap 保持一行，避免「1 ~ 1000000」在空格处折行撑高行高 */
.table td .cell-edit.qty-edit { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* 只改富文本字段的弹窗：编辑器比默认 440px 的 modal 宽得多 */
.modal.modal-wide { max-width: 880px; }
.modal.modal-wide .rich-editor-body { min-height: 320px; }
/* 批量上架被跳过的行：一条一个原因，便于逐条核对 */
.modal .skip-list { margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); line-height: 1.7; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr); gap: 18px; align-items: start; }
.panel-title { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 10px; text-transform: uppercase; letter-spacing: .04em; }
.sub-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; background: #fff; }
.tree-row td:first-child { padding-left: 12px; }
.tree-row.level-2 td:first-child { padding-left: 40px; }
.tree-row.level-2 { background: #fcfcfe; }
.toggle-btn { border: 0; background: transparent; cursor: pointer; color: var(--muted); padding: 0 6px 0 0; }
.raw-json {
  background: #0f172a; color: #e2e8f0; border-radius: var(--radius-sm);
  padding: 12px; font-size: 12px; max-height: 280px; overflow: auto;
  white-space: pre-wrap; word-break: break-all;
}
.totp-box { border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 12px; background: #f9fafb; }
.bot-text-item { border-top: 1px solid var(--border); padding-top: 18px; margin-top: 18px; }
.bot-text-item:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.bot-text-item textarea { width: 100%; }
.totp-box .secret { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-all; }

/* 系统设置：一项一块，数值输入不长于卡片宽度 */
.setting-item { border-top: 1px solid var(--border); padding-top: 18px; margin-top: 18px; max-width: 520px; }
.setting-item:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.setting-item .field > label { display: flex; align-items: center; gap: 8px; }
.setting-item .field { margin-bottom: 12px; }

/* 商品详情富文本编辑器（web/assets/js/admin/richtext.js）。
   CSP 是 style-src 'self'，编辑器只能产出标签，外观一律走这些 class。 */
.rich-editor {
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; overflow: hidden;
}
.rich-editor:focus-within { border-color: var(--primary); }
.rich-editor-toolbar {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 8px; border-bottom: 1px solid var(--border); background: #fbfbfd;
}
.rich-editor-btn {
  min-height: 30px; min-width: 32px; padding: 3px 8px;
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  background: #fff; color: var(--muted); font-size: 12px; line-height: 1.4; cursor: pointer;
}
.rich-editor-btn.wide { padding: 3px 10px; }
.rich-editor-btn:hover { border-color: var(--border-strong); background: var(--hover); color: var(--text); }
.rich-editor-btn.active {
  border-color: var(--primary); background: var(--primary-soft);
  color: var(--primary-dark); font-weight: 700;
}
.rich-editor-btn.strong { font-weight: 800; }
.rich-editor-btn.em { font-style: italic; }
.rich-editor-btn.under { text-decoration: underline; }
.rich-editor-btn.strike { text-decoration: line-through; }
.rich-editor-body {
  min-height: 280px; max-height: 560px; overflow: auto; outline: none;
  padding: 12px 14px; font-size: 13px; line-height: 1.75; color: var(--muted);
}
.rich-editor-body:empty::before { content: attr(data-placeholder); color: var(--faint); }
/* 正文排版对齐前台 .rich-text（web/channels/site_a/assets/css/site.css） */
.rich-editor-body p, .rich-editor-body div { margin: 0 0 9px; }
.rich-editor-body h1, .rich-editor-body h2, .rich-editor-body h3,
.rich-editor-body h4, .rich-editor-body h5, .rich-editor-body h6 {
  margin: 10px 0 8px; font-size: 15px; font-weight: 700; color: var(--text);
}
.rich-editor-body ul, .rich-editor-body ol { margin: 0 0 9px; padding-left: 22px; }
.rich-editor-body li { margin-bottom: 4px; }
.rich-editor-body blockquote {
  margin: 0 0 9px; padding: 6px 10px;
  border-left: 3px solid var(--border-strong); color: var(--faint);
}
.rich-editor-body hr { border: 0; border-top: 1px solid var(--border-strong); margin: 10px 0; }
.rich-editor-body a { color: var(--primary); word-break: break-all; }
.rich-editor-body table { border-collapse: collapse; margin-bottom: 9px; max-width: 100%; }
.rich-editor-body th, .rich-editor-body td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; }
.rich-editor-body code, .rich-editor-body pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--surface-2); border-radius: var(--radius-xs); font-size: 12px;
}
.rich-editor-body pre { padding: 8px 10px; white-space: pre-wrap; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 20px; border-left: 2px solid var(--border); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--primary); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border);
}
.timeline .time { color: var(--muted); font-size: 12px; }
.timeline .msg { font-size: 13px; margin-top: 4px; }

.admin-login-wrap {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px;
  background: #0f172a;
}
.admin-login-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border-radius: 12px; padding: 28px; box-shadow: var(--shadow-lg);
}
.admin-login-card h1 { font-size: 20px; margin-bottom: 4px; }
.admin-login-card .sub { color: var(--muted); font-size: 12px; margin-bottom: 20px; }

@media (max-width: 960px) {
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { flex-direction: row; align-items: center; overflow-x: auto; }
  .admin-sidebar .brand { border-bottom: 0; white-space: nowrap; padding: 12px 16px; }
  .admin-nav { flex-direction: row; padding: 8px; }
  .admin-nav .group { display: none; }
  .admin-nav a { white-space: nowrap; }
  .detail-grid { grid-template-columns: 1fr; }
  .admin-content { padding: 16px; }
}

/* 订单详情 · 发货明细（明文）：与前台订单详情一致的一条一卡，字段两列排布、
   CK 折叠在卡片内独立滚动；任何窗口宽度下都不会出现列挤压、截断或横向滚动条。 */
.dv-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 12px; }
.dv-list { display: flex; flex-direction: column; gap: 10px; }
.dv-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fbfbfd;
  padding: 12px 14px;
}
.dv-acts { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.dv-fields { display: flex; flex-direction: column; gap: 4px; }
.dv-field {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 10px;
  font-size: 12.5px;
  line-height: 1.8;
}
.dv-field .k { color: var(--faint); }
.dv-field .v {
  color: var(--text);
  word-break: break-all;
  font-family: Consolas, Menlo, monospace;
}
.dv-fold { margin-top: 10px; border-top: 1px dashed var(--border); padding-top: 10px; }
.dv-fold > summary { cursor: pointer; font-size: 12px; color: var(--primary); user-select: none; }
.dv-fold[open] > summary { margin-bottom: 8px; }
.dv-fold .raw-json { max-height: 220px; }
