:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --surface: #faf8f4;
  --text: #13263b;
  --muted: #5f6d7e;
  --border: #e5dfd3;
  --border-strong: #d4cab8;
  --primary: #13263b;
  --primary-hover: #1e3a59;
  --gold: #c69334;
  --gold-soft: #f7efe0;
  --accent: #b88326;
  --danger: #b42318;
  --ok: #156f46;
  --ok-bg: #e7f6ee;
  --warn-bg: #fdf3dc;
  --warn-text: #8c5a08;
  --shadow-sm: 0 1px 2px rgba(19, 38, 59, 0.04), 0 2px 8px rgba(19, 38, 59, 0.03);
  --shadow-md: 0 8px 28px rgba(19, 38, 59, 0.08);
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
.container { max-width: 1180px; margin: 0 auto; padding: 22px 20px 48px; }
.container-sm { max-width: 720px; margin: 0 auto; padding: 18px 16px 48px; }

.topbar {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 18px; color: var(--primary); letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
.brand-logo { height: 34px; width: auto; display: block; }
.login-logo { max-width: 190px; height: auto; display: block; margin: 0 auto 18px; }

.tabs {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 6px 20px 10px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 1px solid transparent;
  background: transparent;
  padding: 8px 15px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  min-height: 38px;
  transition: all 0.16s ease;
}
.tab:hover { color: var(--primary); background: var(--surface); }
.tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(19, 38, 59, 0.18);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.card-title { font-size: 17px; font-weight: 700; margin: 0 0 12px; color: var(--primary); letter-spacing: -0.01em; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}
.btn:hover { background: var(--surface); border-color: var(--primary); }
.btn-lg { min-height: 46px; font-size: 15px; padding: 11px 20px; }
.btn-sm { min-height: 34px; font-size: 13px; padding: 5px 12px; border-radius: 7px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-accent { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn-accent:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { background: #fff; border-color: #f3c4c0; color: var(--danger); }
.btn-danger:hover { background: #fef2f2; border-color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.field { margin-bottom: 13px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(198, 147, 52, 0.16);
}
textarea { min-height: 84px; resize: vertical; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #ece8df;
  color: #3a4654;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); }
.badge-danger { background: #feeceb; color: var(--danger); }
.badge-info { background: #e8eef6; color: var(--primary); }
.badge-gold { background: var(--gold-soft); color: #8a6116; }

.price-big { font-size: 24px; font-weight: 800; color: var(--primary); letter-spacing: -0.02em; }
.muted { color: var(--muted); font-size: 13.5px; }

.alert { padding: 12px 15px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; }
.alert-warn { background: var(--warn-bg); color: var(--warn-text); border: 1px solid #f0d89e; }
.alert-err { background: #feeceb; color: var(--danger); border: 1px solid #f6c8c4; }
.alert-ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #b9e4cd; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: var(--surface); font-weight: 700; color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
tbody tr:hover { background: #fcfbf8; }

.thumb { width: 76px; height: 76px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); cursor: pointer; background: var(--surface); }
.thumb-sm { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); }
.thumb-slot { display: flex; flex-direction: column; align-items: center; gap: 5px; flex-shrink: 0; }
.thumb-upload-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 1.5px dashed var(--border-strong); border-radius: 10px; background: var(--surface);
  color: var(--muted); font-size: 11.5px; font-weight: 600; cursor: pointer; padding: 4px;
  transition: all 0.15s;
}
.thumb-upload-box:hover { border-color: var(--gold); color: var(--primary); background: var(--gold-soft); }
.thumb-wrap {
  position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--border);
  cursor: pointer; background: var(--surface);
}
.thumb-count {
  position: absolute; right: 4px; bottom: 4px; background: rgba(19, 38, 59, 0.78);
  color: #fff; font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 999px;
}
.thumb-manage-btn {
  width: 100%; border: 1px solid var(--border-strong); background: #fff; color: var(--primary);
  font-size: 11.5px; font-weight: 600; padding: 3px 4px; border-radius: 6px; cursor: pointer;
}
.thumb-manage-btn:hover { background: var(--gold-soft); border-color: var(--gold); }
.pm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 12px; margin-top: 12px; }
.pm-card {
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface);
  display: flex; flex-direction: column;
}
.pm-card.is-main { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(198,147,52,0.2); }
.pm-img-box { position: relative; aspect-ratio: 1 / 1; background: #eee; cursor: pointer; }
.pm-img-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pm-main-tag {
  position: absolute; top: 6px; left: 6px; background: var(--gold); color: #fff;
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
}
.pm-actions { display: flex; gap: 4px; padding: 6px; background: #fff; border-top: 1px solid var(--border); }
.pm-actions button { flex: 1; min-height: 30px; padding: 3px 6px; font-size: 12px; }

.modal-mask {
  position: fixed; inset: 0; background: rgba(19, 38, 59, 0.48); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center; z-index: 50; padding: 14px;
}
@media (min-width: 640px) { .modal-mask { align-items: center; } }
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 640px;
  max-height: 92vh; overflow-y: auto; padding: 22px; box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--primary); color: #fff; padding: 11px 22px; border-radius: 999px;
  font-size: 14px; font-weight: 600; z-index: 100; box-shadow: 0 10px 28px rgba(19,38,59,0.28);
}
.hidden { display: none !important; }
@media print {
  body { background: #fff; font-size: 12px; }
  .no-print { display: none !important; }
  .card { border: none; padding: 0; box-shadow: none; }
  .container { max-width: 100%; padding: 0; }
}
