/* ══════════════════════════════════════════
   衣舍 · 管理后台专用样式
   —— 复用 base.css 的变量与通用类，只在后台补充布局
   ══════════════════════════════════════════ */

:root {
  /* 后台比前台略深一点的底，卡片保持纯白，工具感更强 */
  --admin-bg: #f2eeea;
  --admin-top-h: 58px;
  --ok: var(--wechat-dark);          /* 复用基座的微信绿，不另起配色 */
  --ok-soft: rgba(7, 193, 96, .1);
  --danger: var(--accent);
  --danger-soft: rgba(177, 84, 61, .09);
  --admin-wrap: 960px;
}

/* ───────── 基础 ───────── */

body.admin-body {
  min-height: 100vh;
  background-color: var(--admin-bg);
  background-image: radial-gradient(1100px 380px at 50% -200px, #ffffff 0%, rgba(255, 255, 255, 0) 72%);
  background-repeat: no-repeat;
}

body.modal-open { overflow: hidden; }

/* 后台里所有 input 统一 16px 触控友好高度 */
.admin-body .input,
.admin-body .textarea { font-size: 14.5px; }

/* 请求进行中的按钮 */
.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  pointer-events: none;
  transform: none !important;
  box-shadow: none;
}
.btn-xs {
  padding: 7px 13px;
  font-size: 12.5px;
  border-radius: 9px;
  font-weight: 700;
}

/* ══════════════════════════════════════════
   登录门
   ══════════════════════════════════════════ */

.login-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 20px 40px;
}

.login-card {
  width: 100%;
  max-width: 372px;
  padding: 30px 26px 22px;
  border-radius: 20px;
  text-align: center;
  animation: fadeUp .35s ease both;
}
.login-logo {
  font-family: var(--font-serif);
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: .1em;
  color: var(--ink);
  text-indent: .1em;      /* 抵消字间距造成的视觉偏左 */
}
.login-sub {
  margin-top: 6px;
  font-size: 11.5px;
  letter-spacing: .34em;
  text-indent: .34em;
  color: var(--muted);
  font-weight: 700;
}
.login-card .field {
  margin: 24px 0 6px;
  text-align: left;
}
.login-error {
  min-height: 19px;
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--danger);
  text-align: left;
  line-height: 1.4;
}
.login-foot {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* ══════════════════════════════════════════
   顶栏 + 标签页
   ══════════════════════════════════════════ */

.admin-top {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, .93);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.top-inner {
  max-width: var(--admin-wrap);
  margin-inline: auto;
  padding-inline: var(--pad);
}
.top-row {
  height: var(--admin-top-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand-mark {
  display: flex;
  align-items: baseline;
  gap: 9px;
  min-width: 0;
}
.brand-name {
  font-family: var(--font-serif);
  font-size: 19px;
  letter-spacing: .07em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-sub {
  font-size: 11px;
  letter-spacing: .18em;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.tabs {
  display: flex;
  gap: 26px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 0 1px 11px;
  margin-bottom: -1px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s ease, border-color .15s ease;
}
.tab:hover { color: var(--ink-2); }
.tab.is-active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}
.tab:focus-visible {
  outline: 2px solid rgba(177, 84, 61, .35);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ══════════════════════════════════════════
   主体布局
   ══════════════════════════════════════════ */

.admin-main.wrap {
  max-width: var(--admin-wrap);
  padding-top: 22px;
  padding-bottom: 104px;   /* 给底部保存条留位置 */
}

.panel { animation: fadeUp .25s ease both; }

.panel-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.panel-title {
  font-family: var(--font-serif);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: .02em;
  margin: 0;
}
.panel-note {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

/* ───────── 分组卡片 ───────── */

.group {
  padding: 20px 22px 6px;
  margin: 0 0 16px;
  border-radius: var(--r-m);
}
.group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-2);
}
.group-title {
  font-family: var(--font-serif);
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: .02em;
  margin: 0;
  color: var(--ink);
}
.group-note {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}
.group-foot {
  padding: 2px 0 14px;
}

/* 两列表单网格；窄屏退化为单列 */
.fgrid { display: grid; gap: 0 18px; }
.fgrid .field { margin-bottom: 15px; }
.fgrid .span2 { grid-column: 1 / -1; }

@media (min-width: 760px) {
  .fgrid { grid-template-columns: 1fr 1fr; }
}

/* 必填 / 提示小标记 */
.req {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .02em;
  vertical-align: 1px;
}
.req-soft {
  margin-left: 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}

/* ══════════════════════════════════════════
   图片字段（二维码 / 主图）
   ══════════════════════════════════════════ */

.imgfield {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.imgfield .thumb {
  width: 96px;
  height: 96px;
  flex: none;
  border-radius: 12px;
  border: 1px dashed var(--line);
  background: var(--surface-2);
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.2;
  text-align: center;
}
.imgfield .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.imgfield .thumb.qr-thumb { background: #fff; }
.imgfield .thumb.qr-thumb img { object-fit: contain; padding: 4px; }
.imgfield-side { flex: 1 1 auto; min-width: 0; }
.imgfield-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 9px;
}
.up-status {
  font-size: 12px;
  color: var(--muted);
  min-height: 1em;
}
.up-status.is-busy { color: var(--accent); }

/* 附图网格 */
.imgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(82px, 1fr));
  gap: 10px;
  margin-bottom: 2px;
}
.imgcell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line-2);
  background: var(--surface-2);
}
.imgcell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.imgcell-del {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(29, 26, 24, .6);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  backdrop-filter: blur(4px);
}
.imgcell-del:hover { background: var(--danger); }
.imgcell-add {
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease;
  padding: 0;
  border-radius: 12px;
}
.imgcell-add:hover { border-color: var(--accent); color: var(--accent); }

/* 附图序号角标（第一张标「封面」） */
.imgcell-idx {
  position: absolute;
  top: 5px;
  left: 5px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(29, 26, 24, .78);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .03em;
  line-height: 1.4;
  backdrop-filter: blur(4px);
  pointer-events: none;
}
/* 第一张（封面）用强调色 */
.imgcell:first-child .imgcell-idx {
  background: linear-gradient(135deg, #16cd6f, #0aa657);
}

/* 左右挪位按钮 */
.imgcell-move {
  position: absolute;
  bottom: 5px;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .94);
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0 0 2px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
  transition: background .15s ease, transform .12s ease;
}
.imgcell-move:hover { background: #fff; transform: scale(1.08); }
.imgcell-move--prev { left: 5px; }
.imgcell-move--next { left: 33px; }

/* ══════════════════════════════════════════
   底部保存条
   ══════════════════════════════════════════ */

.savebar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 35;
  background: rgba(255, 255, 255, .93);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.savebar-inner {
  max-width: var(--admin-wrap);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-top: 11px;
  padding-bottom: 11px;
}
.save-state {
  font-size: 12.5px;
  color: var(--muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.save-state.is-dirty {
  color: var(--accent);
  font-weight: 700;
}

/* ══════════════════════════════════════════
   款式列表
   ══════════════════════════════════════════ */

.plist { overflow: hidden; padding: 0; }

.prow {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border-top: 1px solid var(--line-2);
  transition: background .15s ease;
}
.prow:first-child { border-top: 0; }
.prow:hover { background: #fdfbf9; }

.pthumb {
  width: 76px;
  height: 76px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
  flex: none;
}
.pthumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pinfo { min-width: 0; }
.ptop {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}
.ptitle {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.pprice {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: .01em;
}
.chip-muted {
  background: var(--surface-2);
  color: var(--muted);
}
.pdesc {
  margin: 5px 0 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.pops {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.op-danger {
  color: var(--danger);
  border-color: rgba(177, 84, 61, .28);
}
.op-danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}
.op-up {
  color: var(--ok);
  border-color: rgba(47, 143, 91, .3);
}
.op-up:hover {
  background: var(--ok-soft);
  border-color: var(--ok);
  color: var(--ok);
}

.empty {
  padding: 42px 20px;
  text-align: center;
  font-size: 13.5px;
  color: var(--muted);
}

/* 窄屏：列表行两栏，操作换行占满 */
@media (max-width: 719px) {
  .prow {
    grid-template-columns: 62px minmax(0, 1fr);
    gap: 12px 14px;
    padding: 13px 14px;
    align-items: start;
  }
  .pthumb { width: 62px; height: 62px; border-radius: 10px; }
  .pops {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
  .pdesc { -webkit-line-clamp: 2; }
}

/* ══════════════════════════════════════════
   弹层
   ══════════════════════════════════════════ */

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 4vh, 40px) 16px;
  background: rgba(29, 26, 24, .44);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: maskIn .18s ease both;
}
@keyframes maskIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  width: 100%;
  max-width: 620px;
  max-height: min(88vh, 860px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--r-m);
  box-shadow: var(--sh-3);
  animation: modalIn .22s ease both;
  overflow: hidden;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(.99); }
  to   { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line-2);
  flex: none;
}
.modal-head__right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
}
.modal-head__right .switch {
  margin: 0;
  padding-right: 12px;
  border-right: 1px solid var(--line-2);
  font-size: 12.5px;
}
.switch--sm { font-size: 12.5px; }
.modal-title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .02em;
  margin: 0;
}
.modal-close {
  width: 32px;
  height: 32px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0 0 2px;
  transition: border-color .15s ease, color .15s ease;
}
.modal-close:hover { border-color: var(--ink); color: var(--ink); }

.modal-body {
  padding: 18px 20px 4px;
  overflow-y: auto;
  flex: 1 1 auto;
  -webkit-overflow-scrolling: touch;
}
.modal-body .field:last-of-type { margin-bottom: 18px; }

.modal-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--line-2);
  background: #fdfbf9;
  flex: none;
}
.modal-hint {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 手机：弹层全屏 */
@media (max-width: 640px) {
  .modal-mask { padding: 0; align-items: stretch; }
  .modal {
    max-width: 100%;
    max-height: none;
    height: 100dvh;
    border-radius: 0;
    animation: modalInMobile .2s ease both;
  }
  @keyframes modalInMobile {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: none; }
  }
  .modal-head { padding-top: max(16px, env(safe-area-inset-top, 0px)); }
  .modal-body { padding-inline: 16px; }
  .modal-foot {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .modal-foot .btn { flex: 1 1 auto; }
  .modal-hint { display: none; }
}

/* ══════════════════════════════════════════
   开关
   ══════════════════════════════════════════ */

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-2);
  margin-bottom: 18px;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.switch .track {
  width: 44px;
  height: 26px;
  flex: none;
  border-radius: var(--r-pill);
  background: var(--line);
  position: relative;
  transition: background .18s ease;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  transition: transform .18s ease;
}
.switch input:checked + .track { background: var(--wechat); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px rgba(177, 84, 61, .22); }

/* ══════════════════════════════════════════
   Toast
   ══════════════════════════════════════════ */

.toast-wrap {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(92vw, 420px);
  pointer-events: none;
}
.toast {
  max-width: 100%;
  padding: 10px 18px;
  border-radius: var(--r-pill);
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.4;
  color: #fff;
  box-shadow: var(--sh-2);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity .2s ease, transform .2s ease;
  overflow-wrap: anywhere;
}
.toast.in { opacity: 1; transform: none; }
.toast-ok {
  background: linear-gradient(180deg, #16cd6f, var(--wechat-dark));
  box-shadow: 0 8px 22px rgba(6, 165, 82, .3);
}
.toast-err { background: var(--accent); }

/* ══════════════════════════════════════════
   窄屏微调
   ══════════════════════════════════════════ */

@media (max-width: 640px) {
  .top-inner { padding-inline: 16px; }
  .brand-sub { display: none; }
  .admin-main.wrap { padding-inline: 14px; padding-top: 16px; }
  .group { padding: 16px 14px 2px; }
  .group-head { margin-bottom: 14px; }
  .panel-head { align-items: center; }
  .panel-title { font-size: 19px; }
  .imgfield .thumb { width: 78px; height: 78px; }
  .imgfield { gap: 11px; }
  .savebar-inner { padding-inline: 16px; }
  .tab { font-size: 13.5px; }
  .tabs { gap: 22px; }
}

@media (max-width: 380px) {
  .top-actions .btn-xs { padding: 6px 10px; font-size: 12px; }
}
