/* ============================================================
   府中府家居 · 管理后台样式
   沿用小程序端设计契约：主色 #0071E3，中性墨色层级，卡片圆角 14px
   ============================================================ */

:root {
  --accent: #0071E3;
  --accent-hover: #0077ED;
  --accent-soft: #E8F2FE;
  --accent-ink: #0A5CBF;

  --ink: #1D1D1F;
  --ink-2: #6E6E73;
  --ink-3: #86868B;
  --ink-4: #AEAEB2;

  --bg: #F5F5F7;
  --card: #FFFFFF;
  --line: #E8E8ED;
  --line-soft: #F0F0F3;

  --ok: #1B7F5A;
  --ok-soft: #E4F5EC;
  --warn: #9A6400;
  --warn-soft: #FDF3DC;
  --out: #B03A3A;
  --out-soft: #FBEAEA;
  --info: #0A5CBF;
  --info-soft: #E8F2FE;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.05);
  --shadow-lg: 0 12px 48px rgba(0,0,0,.16);

  --side-w: 236px;
  --top-h: 74px;
}

* { box-sizing: border-box; }

/* hidden 属性必须压过 display:flex 之类的布局声明 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.02em; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--line-soft);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 12px;
}

/* ---------------- 登录 ---------------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(900px 480px at 50% -10%, #E8F2FE 0%, rgba(232,242,254,0) 70%),
    var(--bg);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 36px 32px 28px;
}

.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 30px; }

.login-logo {
  width: 46px; height: 46px;
  border-radius: 13px;
  background: var(--ink);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 600;
}

.login-brand h1 { font-size: 19px; }
.login-brand p { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }

.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block;
  font-size: 12.5px;
  color: var(--ink-2);
  margin-bottom: 7px;
  font-weight: 500;
}

input[type="text"], input[type="password"], input[type="number"],
input[type="search"], select, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,113,227,.12);
}

input::placeholder, textarea::placeholder { color: var(--ink-4); }
textarea { resize: vertical; min-height: 78px; line-height: 1.6; }
select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5L6 8l3.5-3.5' stroke='%2386868B' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 30px; }

.login-error {
  background: var(--out-soft);
  color: var(--out);
  font-size: 13px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}

.login-hint {
  margin-top: 20px;
  font-size: 12px;
  color: var(--ink-3);
  text-align: center;
  line-height: 1.7;
}

/* ---------------- 按钮 ---------------- */

.btn {
  font: inherit;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  cursor: pointer;
  transition: background .16s, border-color .16s, opacity .16s, color .16s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
}

.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { background: var(--card); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover:not(:disabled) { border-color: var(--ink-4); }
.btn-soft { background: var(--accent-soft); color: var(--accent-ink); }
.btn-soft:hover:not(:disabled) { background: #D9E9FC; }
.btn-danger { background: var(--out-soft); color: var(--out); }
.btn-danger:hover:not(:disabled) { background: #F6DADA; }
.btn-block { width: 100%; padding: 11px; font-size: 15px; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 7px; }
.btn-link {
  background: none; border: none; color: var(--accent); cursor: pointer;
  font: inherit; font-size: 13px; padding: 2px 4px; border-radius: 5px;
}
.btn-link:hover { background: var(--accent-soft); }
.btn-link.danger { color: var(--out); }
.btn-link.danger:hover { background: var(--out-soft); }

/* ---------------- 布局 ---------------- */

.app { display: flex; height: 100dvh; overflow: hidden; }

.sidebar {
  width: var(--side-w);
  flex: 0 0 var(--side-w);
  background: var(--card);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.side-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 20px 18px 18px;
}

.side-logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--ink); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 600; flex: none;
}

.side-brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.side-brand-text strong { font-size: 15px; }
.side-brand-text span { font-size: 11.5px; color: var(--ink-3); }

.side-nav { flex: 1; padding: 6px 10px; overflow-y: auto; }

.side-group {
  font-size: 11px;
  color: var(--ink-4);
  padding: 14px 10px 6px;
  letter-spacing: .04em;
  font-weight: 600;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px;
  border-radius: 9px;
  color: var(--ink-2);
  cursor: pointer;
  font-size: 13.5px;
  margin-bottom: 2px;
  transition: background .14s, color .14s;
  user-select: none;
}

.nav-item:hover { background: var(--line-soft); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav-item .ico { width: 17px; height: 17px; flex: none; }
.nav-item .badge-dot {
  margin-left: auto;
  background: var(--out);
  color: #fff;
  font-size: 11px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  padding: 0 5px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
}

.side-foot { border-top: 1px solid var(--line); padding: 12px; }
.side-user { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.side-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px; flex: none;
}
.side-user-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.side-user-text strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user-text span { font-size: 11px; color: var(--ink-3); }

.side-logout {
  width: 100%; font: inherit; font-size: 12.5px;
  padding: 7px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card);
  color: var(--ink-2); cursor: pointer;
}
.side-logout:hover { border-color: var(--out); color: var(--out); }

.main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--top-h);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  background: rgba(245,245,247,.82);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}

.topbar h2 { font-size: 20px; }
.topbar-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.api-chip {
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--line-soft);
  color: var(--ink-3);
}
.api-chip.on { background: var(--ok-soft); color: var(--ok); }
.api-chip.off { background: var(--out-soft); color: var(--out); }

.view { padding: 18px 24px; flex: 1; min-height: 0; overflow: auto; }

/* ---------------- 卡片 / 栅格 ---------------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.card + .card { margin-top: 16px; }

.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
.card-head h3 { font-size: 15px; }
.card-head .sub { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }

.grid { display: grid; gap: 14px; }
.grid-kpi { grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 17px 18px;
}
.kpi-label { font-size: 12.5px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 27px; font-weight: 600; letter-spacing: -.03em; margin-top: 6px; }
.kpi-value small { font-size: 14px; font-weight: 500; color: var(--ink-3); margin-left: 3px; }
.kpi-foot { font-size: 12px; color: var(--ink-3); margin-top: 5px; }
.kpi-foot b { color: var(--accent); font-weight: 600; }

/* ---------------- 表格 ---------------- */

/* 横向滚动容器：不做出血负边距，避免表格被卡片边缘裁掉 */
.table-wrap { height: clamp(240px, calc(100dvh - 320px), 680px); overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; scrollbar-gutter: stable; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th {
  position: sticky; top: 0; z-index: 2;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: var(--card);
}
table.tbl td {
  padding: 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
table.tbl tbody tr:hover { background: #FAFAFC; }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl .nowrap { white-space: nowrap; }
table.tbl .col-act { text-align: right; white-space: nowrap; }

/* 操作列吸附在右侧：表格横向滚动时按钮始终可见，不会被裁掉 */
table.tbl th.col-act,
table.tbl td.col-act {
  position: sticky;
  right: 0;
  background: var(--card);
  box-shadow: -10px 0 12px -10px rgba(0, 0, 0, .14);
  z-index: 1;
}
table.tbl tbody tr:hover td.col-act { background: #FAFAFC; }

.cell-main { font-weight: 500; }
.cell-sub { font-size: 12px; color: var(--ink-3); margin-top: 1px; }

.thumb {
  width: 46px; height: 46px; border-radius: 9px;
  object-fit: cover; background: var(--line-soft);
  flex: none; display: block;
}

.thumb-ph {
  width: 46px; height: 46px; border-radius: 9px;
  background: var(--line-soft); color: var(--ink-4);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex: none;
}

.product-image-button {
  border: 0; padding: 0; background: transparent; border-radius: 9px;
  flex: none; cursor: zoom-in;
}
.product-image-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.product-image-preview { display: flex; justify-content: center; align-items: center; min-height: 160px; }
.product-image-preview img {
  display: block; max-width: 100%; max-height: calc(100vh - 220px);
  width: auto; height: auto; object-fit: contain;
}
.product-image-preview img[hidden] { display: none; }
.product-image-preview p { color: var(--ink-3); text-align: center; }

.cell-flex { display: flex; align-items: center; gap: 11px; min-width: 0; }
.cell-flex .txt { min-width: 0; }
.cell-flex .txt strong { font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-flex .txt .cell-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }

.price { font-variant-numeric: tabular-nums; font-weight: 600; }
.origin { font-weight: 400; color: var(--ink-4); text-decoration: line-through; font-size: 12px; margin-left: 6px; }

/* ---------------- 状态标签 ---------------- */

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; padding: 2.5px 9px; border-radius: 20px;
  font-weight: 500; white-space: nowrap;
}
.tag::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.tag-gray { background: var(--line-soft); color: var(--ink-3); }
.tag-blue { background: var(--info-soft); color: var(--info); }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-out { background: var(--out-soft); color: var(--out); }
.tag-plain { background: var(--line-soft); color: var(--ink-2); }
.tag-plain::before { display: none; }

/* ---------------- 工具条 ---------------- */

.toolbar {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; margin-bottom: 16px;
}
.toolbar .grow { flex: 1; min-width: 180px; }
.toolbar input, .toolbar select { width: auto; }
.toolbar .search { min-width: 210px; }

.seg {
  display: inline-flex; background: var(--line-soft); border-radius: 9px; padding: 3px;
}
.seg button {
  font: inherit; font-size: 12.5px; border: none; background: none;
  padding: 5px 13px; border-radius: 7px; cursor: pointer; color: var(--ink-2);
}
.seg button.on { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.06); }

.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 16px; font-size: 13px; color: var(--ink-3); }

@media (min-width: 901px) and (min-height: 540px) {
  .view[data-route="products"] { display: flex; flex-direction: column; overflow: hidden; }
  .view[data-route="products"] > .card { flex-shrink: 0; }
  .view[data-route="products"] > .product-list {
    display: flex; flex-direction: column; flex: 1; min-height: 0;
  }
  .product-list > .card-head, .product-list > .pager { flex-shrink: 0; }
  .view[data-route="products"] .product-list > .table-wrap { height: auto; min-height: 0; flex: 1; }
}

/* ---------------- 空态 / 加载 ---------------- */

.empty { text-align: center; padding: 54px 20px; }
.empty-icon {
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--line-soft); color: var(--ink-4);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px; font-size: 22px;
}
.empty-title { font-size: 15px; font-weight: 500; }
.empty-text { font-size: 13px; color: var(--ink-3); margin-top: 4px; }

.loading { text-align: center; padding: 50px; color: var(--ink-3); font-size: 13px; }

.sk {
  background: linear-gradient(90deg, #F0F0F3 25%, #F7F7F9 37%, #F0F0F3 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 6px;
  height: 14px;
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------------- 图表 ---------------- */

/* viewBox 由 JS 按容器实测宽度生成，宽高一致，不做非等比拉伸 */
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--ink-3); margin-top: 8px; }
.chart-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; }
.bar-row .name { width: 120px; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 8px; background: var(--line-soft); border-radius: 5px; overflow: hidden; display: block; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.bar-row .val { width: 62px; text-align: right; font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------------- 弹窗 ---------------- */

.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.34);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 46px 20px;
  overflow-y: auto;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 620px;
  animation: pop .2s cubic-bezier(.2,.8,.3,1);
  display: flex; flex-direction: column;
  max-height: calc(100vh - 92px);
}
@keyframes pop { from { transform: translateY(10px) scale(.985); opacity: 0; } to { transform: none; opacity: 1; } }

.modal.wide { max-width: 880px; }
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 20px 22px 14px; border-bottom: 1px solid var(--line-soft); gap: 12px;
}
.modal-head h3 { font-size: 16px; }
.modal-head .sub { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.modal-close {
  border: none; background: var(--line-soft); color: var(--ink-2);
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  font-size: 15px; line-height: 1; flex: none;
}
.modal-close:hover { background: var(--line); }
.modal-body { padding: 20px 22px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 14px 22px 18px; border-top: 1px solid var(--line-soft);
  display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap;
}

/* ---------------- 表单排版 ---------------- */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .span2 { grid-column: 1 / -1; }
@media (max-width: 620px) { .form-grid { grid-template-columns: 1fr; } }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs button {
  font: inherit; font-size: 13.5px; border: none; background: none;
  padding: 9px 13px; cursor: pointer; color: var(--ink-3);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.rep-row {
  display: grid; gap: 8px; align-items: start;
  padding: 11px; border: 1px solid var(--line); border-radius: 10px;
  margin-bottom: 9px; background: #FCFCFD;
}
.rep-row .row-head { display: flex; align-items: center; gap: 8px; }
.rep-row .row-head strong { font-size: 12.5px; color: var(--ink-2); flex: 1; }
.rep-actions { display: flex; gap: 6px; }
.icon-btn {
  border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  width: 26px; height: 26px; border-radius: 7px; cursor: pointer; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
}
.icon-btn:hover { border-color: var(--ink-4); }
.icon-btn.danger:hover { border-color: var(--out); color: var(--out); }

.hint { font-size: 12px; color: var(--ink-3); margin-top: 6px; line-height: 1.6; }

/* 单图上传（企业资料封面）：左预览 + 右地址输入与上传按钮 */
.upload-row { display: flex; gap: 16px; align-items: flex-start; }
.upload-thumb {
  width: 200px; height: 112px; object-fit: cover; flex-shrink: 0;
  border-radius: 10px; border: 1px solid var(--line); background: var(--card);
}
.upload-empty {
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--ink-3);
}
.upload-main { flex: 1; min-width: 0; }
.upload-main input[type=file] { margin-top: 10px; font-size: 12.5px; color: var(--ink-2); }
.section-label {
  font-size: 12px; font-weight: 600; color: var(--ink-3);
  letter-spacing: .03em; margin: 4px 0 9px;
}

.kv-list { display: flex; flex-direction: column; gap: 9px; }
.kv { display: flex; gap: 14px; font-size: 13.5px; }
.kv .k { color: var(--ink-3); width: 84px; flex: none; }
.kv .v { flex: 1; min-width: 0; word-break: break-word; }

.item-line {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 0; border-bottom: 1px solid var(--line-soft);
}
.item-line:last-child { border-bottom: none; }
.item-line .txt { flex: 1; min-width: 0; }

.stat-inline { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 16px; }
.stat-inline .it .n { font-size: 20px; font-weight: 600; }
.stat-inline .it .l { font-size: 12px; color: var(--ink-3); }

/* ---------------- Toast ---------------- */

.toast-root {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 9px; align-items: center;
  pointer-events: none;
}

.toast {
  background: rgba(29,29,31,.94);
  color: #fff;
  font-size: 13.5px;
  padding: 9px 17px;
  border-radius: 11px;
  box-shadow: var(--shadow-lg);
  animation: toastIn .22s cubic-bezier(.2,.8,.3,1);
  max-width: 80vw;
}
.toast.ok { background: rgba(27,127,90,.95); }
.toast.err { background: rgba(176,58,58,.95); }
@keyframes toastIn { from { transform: translateY(-10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------- 图片选择器 ---------------- */

.img-pick { display: flex; align-items: center; gap: 12px; }
.img-pick .preview {
  width: 62px; height: 62px; border-radius: 10px; object-fit: cover;
  background: var(--line-soft); flex: none;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-4); font-size: 20px; overflow: hidden;
}
.img-pick .preview img { width: 100%; height: 100%; object-fit: cover; }
.img-pick .ops { flex: 1; display: flex; flex-direction: column; gap: 7px; }
.product-image-opt { margin-top: 4px; padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--line-soft); }
.product-image-opt-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.product-image-opt-row select { width: auto; min-width: 150px; flex: 1; }
.product-image-result { margin-top: 11px; padding-top: 11px; border-top: 1px solid var(--line); }
.product-image-working { color: var(--ink-2); font-size: 12px; padding: 8px 0; }
.product-image-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.product-image-compare > div { min-width: 0; }
.product-image-compare span { display: block; margin-bottom: 5px; color: var(--ink-3); font-size: 11px; }
.product-image-compare img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.product-image-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }

/* ---------------- 响应式 ---------------- */

/* 笔记本宽度：侧栏收成图标轨道，把横向空间让给表格，避免列被挤压 */
@media (min-width: 901px) and (max-width: 1200px) {
  :root { --side-w: 64px; }

  .side-brand { justify-content: center; padding: 18px 0 14px; }
  .side-brand-text { display: none; }

  .side-nav { padding: 6px 8px; }
  .side-group { display: none; }

  .nav-item { justify-content: center; padding: 11px 0; gap: 0; position: relative; }
  .nav-item > span { display: none; }

  .side-user { justify-content: center; }
  .side-user-text { display: none; }

  .side-logout { font-size: 0; padding: 8px 0; }
  .side-logout::before { content: '退出'; font-size: 11px; }
}

/* 窄屏收紧留白，让表格尽可能一屏放下 */
@media (max-width: 1300px) {
  .view { padding: 20px 18px 60px; }
  .topbar { padding: 0 18px; }
  table.tbl { font-size: 13px; }
  table.tbl th { padding: 9px 9px; }
  table.tbl td { padding: 11px 9px; }

  /* 工具条换行时：筛选条件留在上一行，主按钮独占一行并靠右，避免左右参差 */
  .toolbar { row-gap: 10px; }
  .toolbar .grow { flex-basis: 100%; height: 0; min-width: 0; }
  .toolbar > .btn-primary { margin-left: auto; }
}

/* 平板 / 窄窗口：隐藏次要列，让核心信息一屏放下，避免横向滚动 */
@media (max-width: 1100px) {
  table.tbl th.hide-sm, table.tbl td.hide-sm { display: none; }
  table.tbl { min-width: 0 !important; }
}

@media (max-width: 900px) {
  :root { --side-w: 0px; }
  .cell-flex .txt .cell-sub { max-width: 150px; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 60;
    width: 236px; flex-basis: 236px;
    transform: translateX(-100%);
    transition: transform .22s;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .view { padding: 18px 16px 60px; }
  .topbar { padding: 0 16px; }
}

.menu-btn { display: none; }
@media (max-width: 900px) { .menu-btn { display: inline-flex; } }

/* ---------------- 暗色 ---------------- */

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #0A84FF;
    --accent-soft: #12314F;
    --accent-ink: #6FB4FF;
    --ink: #F5F5F7;
    --ink-2: #AEAEB2;
    --ink-3: #8E8E93;
    --ink-4: #636366;
    --bg: #0F0F11;
    --card: #1A1A1D;
    --line: #2C2C30;
    --line-soft: #232326;
    --ok: #4FD39B; --ok-soft: #14311F;
    --warn: #E0B24C; --warn-soft: #33280D;
    --out: #FF6B6B; --out-soft: #3A1D1D;
    --info: #6FB4FF; --info-soft: #12314F;
  }
  body { background: var(--bg); }
  .topbar { background: rgba(15,15,17,.82); }
  table.tbl tbody tr:hover { background: #202024; }
  table.tbl tbody tr:hover td.col-act { background: #202024; }
  table.tbl th.col-act, table.tbl td.col-act { box-shadow: -10px 0 12px -10px rgba(0,0,0,.5); }
  .rep-row { background: #202024; }
  .login-wrap { background: radial-gradient(900px 480px at 50% -10%, #12314F 0%, rgba(18,49,79,0) 70%), var(--bg); }
  .side-logo, .login-logo { background: var(--accent); color: #fff; }
  .seg button.on { box-shadow: none; }
}

/* Fixed desktop overview and independently scrolling data tables. */
.view[data-route="dashboard"] { overflow: hidden; }
.overview { height: 100%; display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.overview-kpis { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; flex-shrink: 0; }
.overview-main { display: grid; grid-template-columns: 1.12fr 1fr; gap: 16px; flex: 1; min-height: 0; }
.overview-main > .card { min-height: 0; margin: 0; display: flex; flex-direction: column; overflow: hidden; }
.overview-main .card-head { flex-shrink: 0; }
.overview-recent-list { display: flex; flex-direction: column; flex: 1; min-height: 0; justify-content: flex-start; }
.overview-booking { display: flex; flex: 0 1 68px; min-height: 40px; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); color: var(--ink); }
.overview-booking > div { min-width: 0; }
.overview-booking .cell-sub { display: block; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.overview-bars { display: flex; flex-direction: column; flex: 1; justify-content: space-around; gap: 9px; min-height: 0; }
.overview-bar { display: flex; align-items: center; gap: 14px; font-size: 12px; }
.overview-bar > span { width: 42px; color: var(--ink-2); }
.overview-bar strong { min-width: 22px; text-align: right; }
.overview-summary { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--ink-2); padding-top: 16px; margin-top: 16px; border-top: 1px solid var(--line); }
.overview-summary b { margin-left: 5px; color: var(--ink); }
.permissions-grid { margin-top: 16px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.permission-row { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 14px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.permission-row:last-child { border: 0; }
.permission-row label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
@media (max-width: 900px) {
  .overview-kpis { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  .overview-main { grid-template-columns: 1fr 1fr; gap: 10px; }
  .overview .kpi { padding: 10px 12px; }
  .overview .kpi-value { font-size: 22px; margin-top: 2px; }
  .overview-booking { min-height: 36px; padding: 5px 0; }
}
@media (max-width: 600px) {
  .view[data-route="dashboard"] { overflow: auto; }
  .overview { height: auto; }
  .overview-main { display: flex; flex-direction: column; }
  .overview-main > .card { min-height: 280px; }
  .table-wrap { height: clamp(260px,calc(100dvh - 300px),600px); }
}

.nav-group { margin: 5px 0 10px; }
.nav-group-toggle { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 11px 14px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.nav-group-toggle:hover { background: var(--line-soft); color: var(--ink); }
.nav-chevron { font-size: 21px; font-weight: 400; line-height: 1; transition: transform .15s; }
.nav-group-toggle[aria-expanded="true"] .nav-chevron { transform: rotate(90deg); }
.nav-children { margin: 0 0 0 11px; padding-left: 8px; border-left: 1px solid var(--line); }
.nav-children .nav-item { margin: 3px 0; }
