/* ============================================================
   藏地甄选 · 管理后台样式
   设计语言与小程序保持同源：米色纸感背景 + 藏红主色 + 金棕点缀
   ============================================================ */
:root {
  --bg: #F4EFE6;
  --card: #FFFFFF;
  --ink: #2A251E;
  --sub: #7A6F5E;
  --line: #E8DFCE;
  --red: #8A2E28;
  --red-deep: #6E241F;
  --red-soft: #F5E4E0;
  --brown: #8A6A45;
  --gold: #B8895A;
  --teal: #5E7178;
  --ok: #3E7D4F;
  --ok-soft: #E4EFE7;
  --danger: #B3372E;
  --danger-soft: #F8E7E5;
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-w: 236px;
  --shadow: 0 6px 24px rgba(42, 37, 30, .08);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { color: inherit; }

/* ============ 登录页 ============ */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1100px 560px at 18% -8%, #F5E4E0 0%, rgba(245,228,224,0) 58%),
    radial-gradient(900px 520px at 108% 108%, #EFE4CE 0%, rgba(239,228,206,0) 55%),
    var(--bg);
  padding: 24px;
}
.login-card {
  width: 400px; max-width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 42px 38px 34px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-logo {
  width: 64px; height: 64px; margin: 0 auto 16px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--red) 0%, var(--gold) 100%);
  color: #fff; font-size: 30px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(138, 46, 40, .28);
}
.login-card h1 { font-size: 22px; letter-spacing: 3px; }
.login-sub { color: var(--sub); font-size: 13px; margin: 8px 0 28px; }
#login-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
#login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--sub); }
#login-form input {
  height: 44px; border: 1px solid var(--line); border-radius: 12px;
  padding: 0 14px; font-size: 14px; background: #FBF9F4; outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
  font-family: inherit; color: var(--ink);
}
#login-form input:focus { border-color: var(--red); background: #fff; box-shadow: 0 0 0 3px rgba(138, 46, 40, .1); }

/* ============ 布局 ============ */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: #241F18; color: #CFC5B2;
  display: flex; flex-direction: column;
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 20;
}
.side-brand { display: flex; gap: 12px; align-items: center; padding: 22px 20px 20px; border-bottom: 1px solid rgba(255,255,255,.07); }
.side-brand .logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, var(--red), var(--gold));
  color: #fff; font-weight: 800; font-size: 19px;
  display: flex; align-items: center; justify-content: center;
}
.side-brand-text b { display: block; color: #fff; font-size: 15px; letter-spacing: 1px; }
.side-brand-text i { font-style: normal; font-size: 11px; color: #9C9078; letter-spacing: 1px; }
.side-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.side-nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 14px; border-radius: 12px;
  color: #CFC5B2; text-decoration: none; font-size: 14px;
  transition: background .15s, color .15s;
}
.side-nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.side-nav a.active { background: var(--red); color: #fff; font-weight: 600; box-shadow: 0 4px 14px rgba(138,46,40,.4); }
.side-nav svg { width: 18px; height: 18px; flex-shrink: 0; }
.side-foot { padding: 16px; border-top: 1px solid rgba(255,255,255,.07); }
.side-foot button {
  width: 100%; height: 38px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,.16); background: transparent;
  color: #CFC5B2; cursor: pointer; font-size: 13px; font-family: inherit;
  transition: border-color .15s, color .15s;
}
.side-foot button:hover { border-color: var(--danger); color: #F5C9C4; }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 64px; background: rgba(255,255,255,.82); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; position: sticky; top: 0; z-index: 10;
}
.topbar h2 { font-size: 18px; letter-spacing: .5px; }
.top-user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--sub); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--red-soft); color: var(--red);
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px;
}
.content { padding: 24px 28px 56px; max-width: 1200px; width: 100%; margin: 0 auto; }

/* ============ 卡片 & 表格 ============ */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 2px 10px rgba(42,37,30,.04);
  overflow: hidden;
}
.card + .card { margin-top: 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 22px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.card-head h3 { font-size: 16px; }
.card-head p { font-size: 12.5px; color: var(--sub); margin-top: 4px; }
.card-narrow { max-width: 620px; }

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12.5px; color: var(--sub); font-weight: 600;
  padding: 12px 22px; background: #FBF8F1; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 14px 22px; border-bottom: 1px solid #F1EADA; font-size: 13.5px; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #FCFAF5; }
.table .thumb {
  width: 52px; height: 52px; border-radius: 10px; object-fit: cover;
  border: 1px solid var(--line); background: #F4EFE6; display: block;
}
.table b { font-weight: 600; }
.muted { color: var(--sub); }
.badge {
  display: inline-block; font-size: 12px; color: var(--brown);
  background: #F0E7D6; border-radius: 7px; padding: 3px 9px; white-space: nowrap;
}
.badge.teal { color: var(--teal); background: #E6EBED; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.off { background: #C9BFAA; box-shadow: 0 0 0 3px #F0EBE0; }
.empty { text-align: center; color: var(--sub); padding: 42px 20px !important; }
.loading-block { text-align: center; color: var(--sub); padding: 60px 0; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 10px; padding: 9px 16px; font-size: 13.5px; cursor: pointer;
  font-family: inherit; transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--brown); color: var(--brown); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-deep); border-color: var(--red-deep); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; height: 44px; font-size: 15px; letter-spacing: 6px; }
.btn-danger-ghost { color: var(--danger); border-color: #EBD2CE; background: #fff; }
.btn-danger-ghost:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn-ghost { border-style: dashed; color: var(--sub); }
.btn-icon {
  width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-size: 14px; color: var(--sub);
  display: inline-flex; align-items: center; justify-content: center; transition: all .15s;
}
.btn-icon:hover:not(:disabled) { border-color: var(--brown); color: var(--brown); }
.btn-icon:disabled { opacity: .3; cursor: not-allowed; }
.btn-icon.danger:hover { border-color: var(--danger); color: var(--danger); }

/* ============ 表单 ============ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 20px 22px 6px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--sub); }
.form-grid input, .form-grid textarea {
  border: 1px solid var(--line); border-radius: 11px;
  padding: 10px 13px; font-size: 13.5px; background: #FBF9F4; outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
  font-family: inherit; color: var(--ink); width: 100%;
}
.form-grid textarea { resize: vertical; line-height: 1.7; }
.form-grid input:focus, .form-grid textarea:focus { border-color: var(--red); background: #fff; box-shadow: 0 0 0 3px rgba(138,46,40,.1); }
.flabel { font-size: 13px; color: var(--sub); }
.check-line { flex-direction: row !important; align-items: center; gap: 8px !important; font-size: 13.5px !important; color: var(--ink) !important; }
.check-line input { width: 16px; height: 16px; accent-color: var(--red); }
.form-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 6px 22px 22px; }
.settings-form { display: flex; flex-direction: column; gap: 16px; padding: 22px; }

/* ============ 特点编辑行 ============ */
.feat-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.feat-row .fr-t { flex: 0 0 200px; }
.feat-row .fr-d { flex: 1; }
.feat-row input {
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
  font-size: 13px; background: #FBF9F4; outline: none; width: 100%;
  font-family: inherit; color: var(--ink); transition: border-color .15s;
}
.feat-row input:focus { border-color: var(--red); background: #fff; }

/* ============ 上传组件 ============ */
.upload-box {
  width: 178px; height: 128px; border: 1.5px dashed #D8CCB2; border-radius: 13px;
  background: #FBF9F4; cursor: pointer; overflow: hidden; position: relative;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, background .15s;
}
.upload-box:hover { border-color: var(--gold); background: #F7F1E3; }
.upload-box img { width: 100%; height: 100%; object-fit: cover; }
.upload-hint { text-align: center; font-size: 12.5px; color: var(--sub); line-height: 1.8; }
.upload-hint small { font-size: 11px; color: #B3A78F; }
.upload-box.uploading::after {
  content: "上传中…"; position: absolute; inset: 0;
  background: rgba(255,255,255,.78); display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; color: var(--brown);
}
.upload-tip { font-size: 11.5px; color: #B3A78F; margin-top: 6px; }

/* ============ 模态框 ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(30, 26, 20, .48);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 20px 40px; z-index: 100; overflow-y: auto;
  animation: fadeIn .18s ease;
}
.modal {
  width: 760px; max-width: 100%;
  background: var(--card); border-radius: 18px;
  box-shadow: 0 24px 60px rgba(30,26,20,.3);
  animation: slideUp .22s ease;
}
.modal.modal-sm { width: 420px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 16px; }
.modal-close {
  border: none; background: transparent; font-size: 22px; line-height: 1;
  color: var(--sub); cursor: pointer; padding: 4px 8px; border-radius: 8px;
}
.modal-close:hover { color: var(--danger); background: var(--danger-soft); }
.modal-body { max-height: 72vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 4px 22px 22px; }
.confirm-text { padding: 26px 22px; font-size: 14px; color: var(--sub); line-height: 1.8; }
.confirm-text b { color: var(--ink); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

/* ============ Toast ============ */
.toast-wrap { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.toast {
  background: rgba(30, 26, 20, .9); color: #fff; font-size: 13px;
  padding: 11px 20px; border-radius: 22px; box-shadow: 0 10px 28px rgba(30,26,20,.3);
  animation: toastIn .2s ease; display: flex; align-items: center; gap: 8px; max-width: 80vw;
}
.toast.ok::before { content: "✓"; color: #8FD3A8; font-weight: 700; }
.toast.err::before { content: "✕"; color: #F2A69F; font-weight: 700; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ============ 响应式 ============ */
@media (max-width: 980px) {
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .sidebar { position: static; width: 100%; }
  .layout { flex-direction: column; }
  .main { margin-left: 0; }
  .side-nav { flex-direction: row; overflow-x: auto; }
  .content { padding: 16px 14px 40px; }
  .table th:nth-child(4), .table td:nth-child(4),
  .table th:nth-child(5), .table td:nth-child(5) { display: none; }
}
