/* =====================================================
   后台样式 V2：深色侧边栏 + 卡片化 + 渐变品牌色
   主色 #1677FF / 与小程序设计系统保持一致
   ===================================================== */
:root {
  --primary: #1677FF;
  --primary-dark: #0E5BD8;
  --primary-light: #E8F3FF;
  --success: #00B42A;
  --warning: #FF7D00;
  --danger: #F53F3F;
  --text-1: #1D2129;
  --text-2: #4E5969;
  --text-3: #86909C;
  --border: #EBEEF5;
  --bg: #F5F7FA;
  --sidebar-bg: #101827;
  --sidebar-bg2: #182238;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-hover: 0 8px 24px rgba(22, 119, 255, 0.10);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text-1);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: var(--primary); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #D3D8E0; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ========== 布局 ========== */
.layout { display: flex; min-height: 100vh; }

/* ========== 侧边栏（深色） ========== */
.sidebar {
  width: 220px;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg2) 100%);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  padding: 24px 20px;
  font-size: 15px;
  font-weight: 600;
  color: #FFFFFF;
  letter-spacing: 0.5px;
}
.sidebar-logo::before {
  content: "";
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1677FF 0%, #69B1FF 100%);
  margin-right: 10px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(22, 119, 255, 0.5);
}
.sidebar-menu { flex: 1; padding: 10px 12px; overflow-y: auto; }
.menu-item {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  margin-bottom: 4px;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.65);
  font-size: 14px;
  transition: all 0.2s ease;
}
.menu-item:hover {
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.06);
}
.menu-item.active {
  background: linear-gradient(90deg, rgba(22, 119, 255, 0.9) 0%, rgba(22, 119, 255, 0.6) 100%);
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(22, 119, 255, 0.35);
}
.menu-icon { display: inline-block; width: 24px; font-size: 15px; }
.sidebar-foot {
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
}
.sidebar-foot a { color: rgba(255, 255, 255, 0.55); transition: color 0.2s; }
.sidebar-foot a:hover { color: #FFFFFF; }

/* ========== 主区域 ========== */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 17px; font-weight: 600; }
.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
}
.topbar-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1677FF 0%, #69B1FF 100%);
  color: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}
.content { padding: 28px; max-width: 1000px; width: 100%; }

/* ========== 卡片 ========== */
.card {
  background: #FFFFFF;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 18px;
  transition: box-shadow 0.25s ease, transform 0.25s ease;
}
.card:hover { box-shadow: var(--shadow-hover); }
.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title::before {
  content: "";
  width: 4px;
  height: 16px;
  border-radius: 2px;
  background: linear-gradient(180deg, #1677FF, #69B1FF);
}
.card-desc { font-size: 12px; color: var(--text-3); margin: -12px 0 18px 12px; }

/* ========== 表单 ========== */
.form-row { display: flex; align-items: center; margin-bottom: 16px; }
.form-row label { width: 130px; color: var(--text-2); flex-shrink: 0; }
.form-row .field { flex: 1; }

input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%;
  max-width: 420px;
  height: 38px;
  border: 1px solid #E0E4EC;
  border-radius: 8px;
  padding: 0 14px;
  font-size: 14px;
  color: var(--text-1);
  background: #FAFBFC;
  outline: none;
  transition: all 0.2s ease;
}
input:hover, select:hover, textarea:hover { border-color: #C9D2E0; }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.12);
}
input[type=file] { font-size: 13px; color: var(--text-2); }
input[type=file]::file-selector-button {
  height: 30px;
  padding: 0 14px;
  margin-right: 10px;
  border: 1px solid #E0E4EC;
  border-radius: 6px;
  background: #FFFFFF;
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
input[type=file]::file-selector-button:hover { border-color: var(--primary); color: var(--primary); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--primary); vertical-align: -3px; }

/* ========== 按钮 ========== */
.btn {
  display: inline-block;
  height: 38px;
  line-height: 38px;
  padding: 0 22px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-primary {
  background: linear-gradient(135deg, #1677FF 0%, #4096FF 100%);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(22, 119, 255, 0.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(22, 119, 255, 0.4); }
.btn-secondary {
  background: #FFFFFF;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-secondary:hover { background: var(--primary-light); }
.btn-danger {
  background: #FFFFFF;
  color: var(--danger);
  border: 1px solid #FBACA3;
}
.btn-danger:hover { background: #FFF1F0; border-color: var(--danger); }
.btn-sm { height: 32px; line-height: 32px; padding: 0 16px; font-size: 13px; border-radius: 6px; }
.btn + .btn { margin-left: 10px; }

/* ========== 提示条 ========== */
.alert {
  padding: 13px 18px;
  border-radius: 10px;
  margin-bottom: 18px;
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid transparent;
}
.alert-success { background: #F0FFF2; color: #009A29; border-color: #AFF0B5; }
.alert-error { background: #FFF1F0; color: #CB2634; border-color: #FBACA3; }
.alert-info { background: #E8F3FF; color: #0E5BD8; border-color: #BEDAFF; }

/* ========== 仪表盘统计卡片 ========== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.stat-card {
  background: #FFFFFF;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all 0.25s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-icon-blue { background: linear-gradient(135deg, #E8F3FF, #BEDAFF); color: #1677FF; }
.stat-icon-green { background: linear-gradient(135deg, #E8FFEA, #AFF0B5); color: #00B42A; }
.stat-icon-orange { background: linear-gradient(135deg, #FFF7E8, #FFE4BA); color: #FF7D00; }
.stat-icon-purple { background: linear-gradient(135deg, #F5E8FF, #DEB8FF); color: #722ED1; }
.stat-num { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ========== 图标预览（自适应：contain 不变形） ========== */
.icon-preview {
  width: 52px;
  height: 52px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background:
    linear-gradient(45deg, #F7F8FA 25%, transparent 25%, transparent 75%, #F7F8FA 75%),
    linear-gradient(45deg, #F7F8FA 25%, #FFFFFF 25%, #FFFFFF 75%, #F7F8FA 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
  margin-right: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.icon-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.icon-empty { color: #C9CDD4; font-size: 11px; text-align: center; line-height: 1.3; }

.banner-preview {
  width: 168px;
  height: 76px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #F7F8FA;
  margin-right: 14px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.banner-preview img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s; }
.banner-preview:hover img { transform: scale(1.05); }

/* ========== 列表行 ========== */
.item-row {
  display: flex;
  align-items: flex-start;
  padding: 18px 0;
  border-bottom: 1px dashed #EDF0F5;
}
.item-row:last-child { border-bottom: none; padding-bottom: 4px; }
.item-body { flex: 1; min-width: 0; }
.item-actions { display: flex; align-items: center; gap: 10px; margin-left: 16px; flex-shrink: 0; }

.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}
.tag-on { background: #E8FFEA; color: #009A29; }
.tag-off { background: #F2F3F5; color: var(--text-3); }
.tag-warn { background: #FFF7E8; color: #FF7D00; }

/* ========== 登录页 ========== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(22, 119, 255, 0.25) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(105, 177, 255, 0.2) 0%, transparent 50%),
    linear-gradient(160deg, #0F172A 0%, #1E293B 100%);
}
.login-card {
  width: 380px;
  background: #FFFFFF;
  border-radius: 16px;
  padding: 44px 36px;
  box-shadow: 0 24px 64px rgba(2, 18, 51, 0.35);
  animation: login-in 0.5s ease;
}
@keyframes login-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.login-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, #1677FF 0%, #69B1FF 100%);
  margin: 0 auto 18px;
  box-shadow: 0 8px 20px rgba(22, 119, 255, 0.4);
}
.login-title { font-size: 20px; font-weight: 700; text-align: center; margin-bottom: 6px; }
.login-sub { font-size: 12px; color: var(--text-3); text-align: center; margin-bottom: 30px; }
.login-card .form-row { display: block; }
.login-card input { max-width: none; margin-bottom: 16px; height: 42px; }
.login-btn { width: 100%; margin-top: 8px; height: 42px; line-height: 42px; font-size: 15px; }

.help-text { font-size: 12px; color: var(--text-3); margin-top: 6px; line-height: 1.7; }
.muted { color: var(--text-3); }
.mt16 { margin-top: 16px; }
