/* ============================================================
   ZONHO 管理后台样式（与官网同一套设计令牌）
   ============================================================ */
:root {
  --bg: #f4f7fc;
  --bg-soft: #e9eff8;
  --surface: #ffffff;
  --surface-2: #eef4fb;
  --line: rgba(30, 58, 95, 0.13);
  --line-strong: rgba(30, 58, 95, 0.24);
  --text: #16233b;
  --muted: #4a5c78;
  --faint: #5f7396;
  --accent: #0a6cc4;
  --accent-soft: rgba(10, 108, 196, 0.09);
  --accent-line: rgba(10, 108, 196, 0.32);
  --accent-ink: #ffffff;
  --danger: #dc2626;
  --ok: #059669;
  --r-card: 14px;
  --r-input: 10px;
  --font: "PingFang SC", "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.65; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- 登录页 ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden; }
.login-wrap::before {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(37, 99, 235, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37, 99, 235, 0.06) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, #000 30%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, #000 30%, transparent 100%);
}
.login-card {
  position: relative; width: 400px; max-width: 100%;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-card); padding: 36px 32px; box-shadow: 0 20px 60px rgba(23, 58, 110, 0.14);
}
.login-card .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; margin-bottom: 6px; }
.login-card .brand .mark {
  width: 36px; height: 36px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #1d6fa8);
  color: var(--accent-ink); display: grid; place-items: center; font-size: 15px; font-weight: 900;
}
.login-card .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 26px; }
.static-notice {
  background: rgba(10, 108, 196, 0.08); border: 1px solid var(--accent-line);
  border-radius: 10px; padding: 12px 14px; font-size: 12.5px; line-height: 1.8;
  color: var(--muted); margin-bottom: 18px;
}
.static-notice b { color: var(--text); }
.static-notice a { color: var(--accent); font-weight: 700; word-break: break-all; }

/* ---------- 表单控件 ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; margin-bottom: 6px; color: var(--muted); }
.field input, .field textarea, .field select {
  width: 100%; background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--r-input);
  color: var(--text); padding: 11px 13px; font-size: 14px; font-family: inherit; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(10, 108, 196, 0.12); }
.field textarea { min-height: 90px; resize: vertical; }
.field .err { display: none; color: var(--danger); font-size: 12px; margin-top: 4px; }
.field.invalid input, .field.invalid textarea { border-color: var(--danger); }
.field.invalid .err { display: block; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 999px; padding: 10px 22px; font-size: 14px; font-weight: 600;
  cursor: pointer; border: 1px solid transparent; white-space: nowrap;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s, border-color 0.2s, color 0.2s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(135deg, #0e7ad6 0%, #0a6cc4 100%); color: #ffffff; box-shadow: inset 0 1px 0 rgba(255,255,255,0.16), 0 4px 14px rgba(10, 108, 196, 0.24); }
.btn-primary:hover { box-shadow: 0 6px 20px rgba(10, 108, 196, 0.3); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(248, 113, 113, 0.4); }
.btn-danger:hover { background: rgba(248, 113, 113, 0.1); }
.btn-sm { padding: 6px 14px; font-size: 12.5px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ---------- 后台布局 ---------- */
.layout { display: none; min-height: 100vh; }
.layout.show { display: block; }
.side {
  position: fixed; left: 0; top: 0; bottom: 0; width: 220px; z-index: 30;
  background: var(--bg-soft); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 14px;
}
.side .logo { display: flex; align-items: center; gap: 9px; font-weight: 800; padding: 4px 10px 16px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.side .logo .mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #1d6fa8);
  color: var(--accent-ink); display: grid; place-items: center; font-size: 14px; font-weight: 900;
}
.side nav { display: grid; gap: 4px; }
.side nav button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: transparent; border: none; color: var(--muted); text-align: left;
  padding: 11px 13px; border-radius: 10px; font-size: 14px; cursor: pointer; transition: all 0.2s;
}
.side nav button:hover { color: var(--text); background: var(--surface); }
.side nav button.on { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.side .foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }
.side .foot a, .side .foot button {
  display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: none;
  color: var(--muted); font-size: 13px; padding: 9px 13px; border-radius: 10px; cursor: pointer; text-align: left;
}
.side .foot a:hover, .side .foot button:hover { color: var(--text); background: var(--surface); }

.main { margin-left: 220px; padding: 26px 30px 50px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.topbar h1 { font-size: 21px; margin: 0; }
.topbar .who { color: var(--muted); font-size: 13.5px; }

/* ---------- 卡片 / 指标 ---------- */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 26px; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 20px 22px; }
.metric .v { font-size: 30px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.metric .l { color: var(--muted); font-size: 13px; margin-top: 2px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 22px 24px; margin-bottom: 22px; }
.panel h2 { font-size: 16.5px; margin: 0 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel .hint { color: var(--faint); font-size: 12.5px; font-weight: 400; }

/* ---------- 表格 ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.8px; }
#msg-table, #product-table, #news-table, #dash-messages { overflow-x: auto; }
.tbl { min-width: 680px; }
@media (max-width: 1200px) { .main .panel .tbl { min-width: 640px; } }
.tbl th, .tbl td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { color: var(--faint); font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.tbl tr:hover td { background: rgba(30, 58, 95, 0.05); }
.tbl .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tbl .muted { color: var(--muted); }
.dot-unread { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 6px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; border: 1px solid var(--line-strong); color: var(--muted); }
.badge.on { border-color: var(--accent-line); color: var(--accent); background: var(--accent-soft); }

.thumb-mini { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-soft); }
.thumb-ph { width: 64px; height: 64px; border-radius: 8px; border: 1px dashed var(--line-strong); display: grid; place-items: center; color: var(--faint); font-size: 10.5px; }

/* ---------- 弹窗 / Toast ---------- */
.mask { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 90; background: rgba(15, 35, 64, 0.45); display: none; align-items: flex-start; justify-content: center; padding: 40px 20px; overflow-y: auto; backdrop-filter: blur(4px); }
.mask.show { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-card); width: 640px; max-width: 100%; padding: 26px 28px; position: relative; box-shadow: 0 20px 60px rgba(23, 58, 110, 0.16); }
.modal h3 { margin: 0 0 18px; font-size: 17px; }
.modal .close { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; }
.modal .close:hover { color: var(--accent); border-color: var(--accent); }
.modal .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(16px); background: var(--surface-2); border: 1px solid var(--accent-line); color: var(--text); padding: 11px 20px; border-radius: 999px; font-size: 13.5px; z-index: 120; opacity: 0; pointer-events: none; transition: all 0.3s; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: rgba(248, 113, 113, 0.5); }

/* 图片上传控件 */
.up-box { display: flex; gap: 14px; align-items: center; }
.up-preview { width: 96px; height: 72px; border-radius: 10px; border: 1px dashed var(--line-strong); display: grid; place-items: center; overflow: hidden; color: var(--faint); font-size: 11px; flex: none; }
.up-preview img { width: 100%; height: 100%; object-fit: cover; }
/* 产品编辑预览框改为 1:1（新闻/轮播/品牌预览不受影响） */
#p-up-preview { width: 96px; height: 96px; }
/* 产品详情图网格 */
.gal-grid { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; flex: 1; }
.gal-tile { position: relative; width: 72px; }
.gal-tile img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-soft); display: block; }
.gal-del { position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font-size: 12px; line-height: 1; cursor: pointer; display: grid; place-items: center; padding: 0; }
.gal-del:hover { border-color: #ef4444; color: #ef4444; }
.gal-ops { display: flex; gap: 4px; margin-top: 4px; }
.gal-ops button { flex: 1; font-size: 11px; padding: 2px 0; border: 1px solid var(--line); background: var(--surface-2); border-radius: 6px; cursor: pointer; color: var(--muted); }
.gal-ops button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.gal-ops button:disabled { opacity: 0.35; cursor: default; }

.feat-chips { margin-bottom: 14px; }
.feat-chips .badge { margin: 0 8px 8px 0; display: inline-flex; align-items: center; gap: 6px; }
.feat-chips .badge button {
  background: none; border: none; color: var(--danger); cursor: pointer;
  font-size: 12px; padding: 0; line-height: 1; font-family: inherit;
}
.feat-chips .badge button:hover { color: #b91c1c; }
#feat-add { max-width: 360px; }

@media (max-width: 900px) {
  .side { width: 64px; padding: 14px 8px; }
  .side .logo .t, .side nav button .t, .side .foot a .t, .side .foot button .t { display: none; }
  .side nav button, .side .foot a, .side .foot button { justify-content: center; padding: 12px; }
  .main { margin-left: 64px; padding: 20px 16px 40px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .modal .row2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
