/* ===== DESIGN TOKENS ===== */
:root {
  --bg-page: #F0EBE5;
  --bg-app: #FAF7F4;
  --card: #FFFFFF;
  --ink: #1A1513;
  --ink2: #5C5350;
  --muted: #A89A92;
  --accent: #D4A9A0;
  --primary: #8B5E55;
  --primary-light: #F5EBE8;
  --primary-dark: #6B4540;
  --danger: #C45B5B;
  --danger-bg: #FDF0F0;
  --success: #5B8C63;
  --success-bg: #F0F8F1;
  --warning: #B8860B;
  --warning-bg: #FFF8E7;
  --line: #E8E0DB;
  --line-light: #F0EBE6;
  --radius: 20px;
  --radius-sm: 14px;
  --radius-xs: 10px;
  --radius-pill: 100px;
  --shadow-sm: 0 1px 3px rgba(26,21,19,.04), 0 1px 2px rgba(26,21,19,.06);
  --shadow: 0 4px 16px rgba(26,21,19,.06);
  --shadow-lg: 0 8px 32px rgba(26,21,19,.1);
  --font: -apple-system, "SF Pro Display", "PingFang SC", "MiSans", "HarmonyOS Sans", "Microsoft YaHei", sans-serif;
  --nav-h: 64px;
  --header-h: 56px;
  --transition: .2s cubic-bezier(.4,0,.2,1);
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
body {
  font-family: var(--font);
  background: var(--bg-page);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== APP SHELL ===== */
.admin-app {
  max-width: 430px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg-app);
  position: relative;
  padding-bottom: var(--nav-h);
}

/* ===== HEADER ===== */
.admin-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 20px;
  background: rgba(250,247,244,.85);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  border-bottom: 0.5px solid rgba(0,0,0,.06);
}
.admin-header .header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
/* 登录/设置页的返回前台链接 */
.admin-front-link {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 60;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(0,0,0,.06);
}
.admin-front-link:active { color: var(--primary); }

.admin-header .header-logo {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius-xs);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}
.admin-header h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.01em;
}
.admin-header .header-action .admin-primary {
  min-height: 36px;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 600;
}

/* ===== MAIN ===== */
.admin-main {
  padding: 16px 16px 8px;
}

/* ===== BOTTOM NAV ===== */
.admin-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(430px, 100%);
  z-index: 100;
  display: flex;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(24px) saturate(1.8);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  border-top: 0.5px solid rgba(0,0,0,.06);
  padding: 4px 0 calc(4px + env(safe-area-inset-bottom));
}
.admin-bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  transition: color var(--transition);
  position: relative;
}
.admin-bottom-nav a svg {
  width: 22px; height: 22px;
  transition: transform var(--transition);
}
.admin-bottom-nav a.active {
  color: var(--primary);
}
.admin-bottom-nav a.active svg {
  transform: scale(1.1);
}
.admin-bottom-nav a:active svg {
  transform: scale(.9);
}

/* ===== METRIC CARDS ===== */
.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.metric-grid article {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow-sm);
  border: 0.5px solid rgba(0,0,0,.04);
  position: relative;
  overflow: hidden;
}
.metric-grid article .metric-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-xs);
  display: grid;
  place-items: center;
  margin-bottom: 12px;
}
.metric-grid article .metric-icon svg {
  width: 18px; height: 18px;
}
.metric-grid article .metric-icon.pink { background: var(--primary-light); color: var(--primary); }
.metric-grid article .metric-icon.green { background: var(--success-bg); color: var(--success); }
.metric-grid article .metric-icon.amber { background: var(--warning-bg); color: var(--warning); }
.metric-grid article .metric-icon.blue { background: #EBF0FF; color: #4A6CF7; }
.metric-grid strong {
  display: block;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.1;
  color: var(--ink);
}
.metric-grid span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin-top: 2px;
  display: block;
}

/* ===== CARDS ===== */
.admin-card {
  background: var(--card);
  border-radius: var(--radius);
  margin-top: 16px;
  box-shadow: var(--shadow-sm);
  border: 0.5px solid rgba(0,0,0,.04);
  overflow: hidden;
}
.admin-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px 14px;
  border-bottom: 0.5px solid var(--line-light);
}
.admin-card-header h2 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.01em;
}
.admin-back {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 4px;
}
.admin-back svg { width: 14px; height: 14px; }

/* Card inner sections */
.card-section {
  padding: 16px 18px;
}
.card-section + .card-section {
  border-top: 0.5px solid var(--line-light);
}
.card-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px 10px;
}
.card-heading h2 { font-size: 14px; font-weight: 700; }
.card-heading span { font-size: 12px; color: var(--muted); font-weight: 500; }

/* Simple rows */
.simple-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-top: 0.5px solid var(--line-light);
}
.simple-row:first-child { border-top: none; }
.simple-row span { font-size: 14px; font-weight: 500; }
.simple-row small { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ===== BUTTONS ===== */
.admin-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 22px;
  border: none;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 2px 8px rgba(139,94,85,.25);
  white-space: nowrap;
}
.admin-primary:hover { box-shadow: 0 4px 16px rgba(139,94,85,.35); transform: translateY(-1px); }
.admin-primary:active { transform: translateY(0); box-shadow: 0 1px 4px rgba(139,94,85,.2); }
.admin-primary svg { width: 16px; height: 16px; }

.admin-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 22px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--card);
  color: var(--ink2);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
}
.admin-secondary:hover { border-color: var(--muted); color: var(--ink); }
.admin-secondary:active { background: var(--line-light); }

.admin-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 22px;
  border: none;
  border-radius: 100px;
  background: rgba(196,91,91,.08);
  color: #C45B5B;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all .2s cubic-bezier(.4,0,.2,1);
}
.admin-danger:hover { background: rgba(196,91,91,.14); }
.admin-danger:active { transform: scale(.98); }

.btn-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-xs);
  border: none;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all var(--transition);
  background: transparent;
}
.btn-icon svg { width: 18px; height: 18px; }
.btn-icon.danger { color: var(--danger); background: var(--danger-bg); }
.btn-icon.danger:hover { background: #FCE0E0; }
.btn-icon.danger:active { transform: scale(.92); }
.btn-icon.success { color: var(--success); background: var(--success-bg); }
.btn-icon.success:hover { background: #E2F0E3; }
.btn-icon.warning { color: var(--warning); background: var(--warning-bg); }
.btn-icon.warning:hover { background: #FFF0D0; }
.btn-icon.edit { color: var(--primary); background: var(--primary-light); }
.btn-icon.edit:hover { background: #EDE0DC; }

.admin-block { width: 100%; }

/* ===== TOAST ===== */
.admin-toast {
  margin: 12px 16px 0;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn .3s cubic-bezier(.4,0,.2,1);
}
.admin-toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.admin-toast.success { background: var(--success-bg); color: var(--success); }
.admin-toast.error { background: var(--danger-bg); color: var(--danger); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== FORMS ===== */
.admin-form { padding: 18px; display: grid; gap: 20px; }

.admin-field { display: grid; gap: 8px; }
.admin-field > label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink2);
  letter-spacing: .01em;
}
.admin-field input,
.admin-field select,
.admin-field textarea {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-size: 15px;
  color: var(--ink);
  transition: all var(--transition);
}
.admin-field input::placeholder,
.admin-field textarea::placeholder { color: var(--muted); }
.admin-field input:focus,
.admin-field select:focus,
.admin-field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.admin-field textarea { height: auto; min-height: 100px; padding: 12px 14px; resize: vertical; line-height: 1.6; }
.admin-field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23A89A92' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}
.field-error {
  font-size: 12px;
  color: var(--danger);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}
.field-error::before {
  content: '!';
  width: 14px; height: 14px;
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
}

/* Input group (inline add) */
.admin-input-group {
  display: flex;
  gap: 10px;
  padding: 18px;
}
.admin-input-group input {
  flex: 1;
  height: 44px;
  padding: 0 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-size: 15px;
  transition: all var(--transition);
}
.admin-input-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.admin-input-group input::placeholder { color: var(--muted); }

/* Checkbox group */
.admin-checkbox-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.admin-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  border: 1.5px solid var(--line);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}
.admin-checkbox:hover { border-color: var(--accent); background: var(--primary-light); }
.admin-checkbox:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
}
.admin-checkbox input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--primary);
  border-radius: 4px;
  flex-shrink: 0;
}

/* ===== FILTERS ===== */
.admin-filters {
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.admin-filters input,
.admin-filters select {
  height: 40px;
  padding: 0 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-xs);
  background: var(--card);
  font-size: 13px;
  color: var(--ink);
  transition: all var(--transition);
}
.admin-filters input::placeholder { color: var(--muted); }
.admin-filters input:focus,
.admin-filters select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.admin-filters select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23A89A92' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}
.admin-filters .admin-primary {
  grid-column: 1 / -1;
  height: 40px;
  min-height: 40px;
  font-size: 13px;
}

/* ===== EMPTY STATE ===== */
.admin-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}
.admin-empty svg {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  opacity: .5;
}
.admin-empty p {
  font-size: 14px;
  font-weight: 500;
  margin: 0;
}
.admin-empty .empty-sub {
  font-size: 12px;
  font-weight: 400;
  margin-top: 6px;
  opacity: .7;
}

/* ===== PRODUCT ITEM ===== */
.product-item {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 18px;
  border-top: 0.5px solid var(--line-light);
}
.product-item:first-child { border-top: none; }
.product-thumb {
  width: 72px; height: 72px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--line-light);
  flex-shrink: 0;
}
.product-thumb img { width: 100%; height: 100%; object-fit: cover; }
.product-thumb-placeholder {
  width: 100%; height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  background: linear-gradient(135deg, #F5F0EB, #EBE4DD);
}
.product-info { min-width: 0; }
.product-brand {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 2px;
}
.product-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}
.product-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-dark);
  font-variant-numeric: tabular-nums;
}
.product-price::before { content: '¥'; font-size: 12px; font-weight: 600; margin-right: 1px; }
.product-spec { font-size: 11px; color: var(--muted); margin-top: 1px; }
.product-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
}
.status-badge.published { background: var(--success-bg); color: var(--success); }
.status-badge.unpublished { background: var(--warning-bg); color: var(--warning); }
.status-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ===== LIST ITEM ===== */
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-top: 0.5px solid var(--line-light);
  transition: background var(--transition);
}
.list-item:first-child { border-top: none; }
.list-item:hover { background: rgba(0,0,0,.01); }
.list-item-name { font-size: 14px; font-weight: 600; }
.list-item-actions { display: flex; gap: 8px; }

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 16px;
}
.pagination a,
.pagination span {
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  color: var(--ink2);
  border: 1.5px solid var(--line);
  transition: all var(--transition);
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ===== AUTH PAGES ===== */
.admin-auth-body {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(160deg, var(--bg-app) 0%, #EDE5DF 50%, #E8DDD6 100%);
}
.admin-auth-card {
  width: min(100%, 380px);
  padding: 36px 24px;
  background: var(--card);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
}
.admin-auth-card .auth-logo {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
}
.admin-auth-card h1 { font-size: 22px; font-weight: 700; margin-bottom: 6px; letter-spacing: -.01em; }
.admin-auth-card p { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.admin-auth-card form { display: grid; gap: 16px; }
.admin-auth-card label { display: grid; gap: 6px; font-size: 13px; color: var(--ink2); font-weight: 600; }
.admin-auth-card input {
  height: 46px;
  padding: 0 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-app);
  font-size: 15px;
  transition: all var(--transition);
}
.admin-auth-card input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  background: var(--card);
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 0; }

/* ===== ANIMATIONS ===== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.admin-card { animation: fadeUp .4s cubic-bezier(.4,0,.2,1) both; }
.admin-card:nth-child(2) { animation-delay: .06s; }
.admin-card:nth-child(3) { animation-delay: .12s; }
.metric-grid article { animation: fadeUp .4s cubic-bezier(.4,0,.2,1) both; }
.metric-grid article:nth-child(1) { animation-delay: .02s; }
.metric-grid article:nth-child(2) { animation-delay: .06s; }
.metric-grid article:nth-child(3) { animation-delay: .1s; }
.metric-grid article:nth-child(4) { animation-delay: .14s; }

/* ============ 上传旋转动画 ============ */
@keyframes spin { to { transform: rotate(360deg); } }
