* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #4f6df5;
  --primary-dark: #3d56d4;
  --primary-light: #eef1fe;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text-main: #1f2937;
  --text-sub: #6b7280;
  --text-light: #9ca3af;
  --border: #e5e7eb;
  --bg: #f0f2f5;
  --card-bg: #ffffff;
  --sidebar-bg: #1e293b;
  --sidebar-hover: #334155;
  --sidebar-active: #4f6df5;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
  background: var(--bg);
  color: var(--text-main);
  font-size: 14px;
}

/* ========== 登录页 ========== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #4f6df5 100%);
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 48px 40px;
  width: 400px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.login-logo {
  width: 64px; height: 64px;
  background: var(--primary);
  color: #fff;
  border-radius: 14px;
  display: inline-flex;
  align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; letter-spacing: 1px;
  margin-bottom: 16px;
}
.login-card h2 { font-size: 20px; margin-bottom: 32px; color: var(--text-main); }
.login-form-admin { display: flex; flex-direction: column; gap: 16px; }
.login-form-admin input {
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  transition: border-color .2s;
}
.login-form-admin input:focus { border-color: var(--primary); }
.btn-login {
  padding: 12px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}
.btn-login:hover { background: var(--primary-dark); }

/* ========== 主界面布局 ========== */
.main-app {
  display: flex;
  min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  left: 0; top: 0;
  z-index: 100;
}
.sidebar-logo {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.logo-mark {
  background: var(--primary);
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 800;
  font-size: 12px;
}
.logo-text { font-size: 15px; font-weight: 600; }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: rgba(255,255,255,0.65);
  cursor: pointer;
  transition: all .15s;
  font-size: 14px;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.nav-icon { font-size: 18px; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.1); display: flex; flex-direction: column; gap: 8px; }
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 2px;
  font-size: 13px;
  color: rgba(255,255,255,0.85);
}
.sidebar-user .avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}
.sidebar-user .user-meta { flex: 1; min-width: 0; }
.sidebar-user .user-name {
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user .user-role { font-size: 11px; color: rgba(255,255,255,0.55); }
.btn-change-pwd {
  width: 100%;
  padding: 8px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.7);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all .15s;
}
.btn-change-pwd:hover { background: rgba(255,255,255,0.1); color: #fff; }
.btn-logout {
  width: 100%;
  padding: 8px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.7);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all .15s;
}
.btn-logout:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* 内容区 */
.content {
  flex: 1;
  margin-left: 220px;
  padding: 24px 32px;
  min-height: 100vh;
}

/* 视图切换 */
.view { display: none; }
.view.active { display: block; }

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.view-header h1 { font-size: 22px; font-weight: 700; }

.btn-add {
  padding: 10px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .2s;
}
.btn-add:hover { background: var(--primary-dark); }

/* ========== 统计卡片 ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.stat-card .stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  margin-bottom: 12px;
}
.stat-card .stat-label { font-size: 13px; color: var(--text-sub); margin-bottom: 4px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; }
.stat-card .stat-change { font-size: 12px; margin-top: 4px; }
.stat-card .stat-change.up { color: var(--success); }
.stat-card .stat-change.down { color: var(--danger); }

/* ========== 图表 ========== */
.dashboard-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.chart-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.chart-card h3 { font-size: 15px; margin-bottom: 16px; }

.bar-chart-item {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.bar-chart-item .label {
  width: 120px;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-chart-item .bar-wrap {
  flex: 1;
  height: 24px;
  background: var(--primary-light);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}
.bar-chart-item .bar {
  height: 100%;
  background: var(--primary);
  border-radius: 6px;
  transition: width .5s ease;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

.trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 200px;
  padding-top: 20px;
}
.trend-bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.trend-bar .bar {
  width: 100%;
  max-width: 40px;
  background: var(--primary);
  border-radius: 6px 6px 0 0;
  min-height: 4px;
  transition: height .5s ease;
  position: relative;
}
.trend-bar .bar .count {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}
.trend-bar .date { font-size: 11px; color: var(--text-sub); }

/* ========== 筛选栏 ========== */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-bar select, .filter-bar input {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  background: #fff;
  min-width: 140px;
}
.filter-bar select:focus, .filter-bar input:focus { border-color: var(--primary); }

/* ========== 批量操作栏 ========== */
.batch-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px 16px;
  background: #eef1fe;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-main);
}
.batch-bar select {
  padding: 6px 10px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  outline: none;
}

/* ========== 数据表格 ========== */
.table-wrap {
  background: var(--card-bg);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  overflow-x: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  background: #f8fafc;
  padding: 12px 16px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.data-table tr:hover td { background: #f8fafc; }
.data-table tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}
.badge.active { background: #dcfce7; color: #166534; }
.badge.inactive { background: #fee2e2; color: #991b1b; }
.badge.paid { background: #dcfce7; color: #166534; }
.badge.pending { background: #fef3c7; color: #92400e; }
.badge.cancelled { background: #f3f4f6; color: #6b7280; }
.badge-role-admin { background: #eef1fe; color: #4f6df5; border: 1px solid #c7d2fe; }
.badge-role-operator { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.badge-role-viewer { background: #f3f4f6; color: #6b7280; border: 1px solid #e5e7eb; }

.role-tip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 12px 16px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-sub);
}

.action-btn {
  padding: 4px 12px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  margin-right: 4px;
  transition: all .15s;
}
.action-btn:hover { border-color: var(--primary); color: var(--primary); }
.action-btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.action-btn.warning { color: #f59e0b; border-color: #f59e0b; }
.action-btn.warning:hover { background: #fef3c7; }

/* ========== 弹窗 ========== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal-dialog {
  background: #fff;
  border-radius: 12px;
  width: 640px;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-dialog.modal-sm { width: 480px; }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 18px; font-weight: 600; }
.modal-close {
  width: 32px; height: 32px;
  border: none;
  background: transparent;
  font-size: 24px;
  color: var(--text-sub);
  cursor: pointer;
  border-radius: 6px;
}
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* 表单 */
.form-row { display: flex; gap: 16px; }
.form-group { flex: 1; margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-sub);
  margin-bottom: 6px;
  font-weight: 500;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
  font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary);
}

.btn-cancel {
  padding: 10px 20px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}
.btn-cancel:hover { background: var(--bg); }
.btn-save {
  padding: 10px 24px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.btn-save:hover { background: var(--primary-dark); }

/* Toast */
.toast {
  display: none;
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-main);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 2000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.toast.show { display: block; animation: slideDown .2s; }
@keyframes slideDown { from { transform: translate(-50%, -100%); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ========== 系统设置 ========== */
.settings-tip {
  background: var(--primary-light);
  border: 1px solid #dbe3fd;
  color: #3d56d4;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 13px;
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.settings-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
}
.settings-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.settings-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.settings-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
}
.settings-status {
  display: inline-block;
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 500;
}
.settings-status-ok { background: #dcfce7; color: #166534; }
.settings-status-warn { background: #fef3c7; color: #92400e; }
.settings-card-body {
  flex: 1;
  border-top: 1px dashed var(--border);
  padding-top: 12px;
}
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
}
.settings-row span { color: var(--text-sub); }
.settings-row b { color: var(--text-main); font-weight: 500; }
.settings-card-note {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
  color: var(--text-light);
  line-height: 1.5;
}
.req { color: #dc2626; }
.field-tip {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-light);
  line-height: 1.5;
}
.field-tip code { background: #f3f4f6; padding: 1px 5px; border-radius: 4px; font-size: 11px; color: #374151; }
.settings-loading {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-light);
  padding: 40px 0;
}
.settings-section h3 {
  font-size: 15px;
  color: var(--text-main);
  margin-bottom: 12px;
}
.method-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  color: #fff;
}
.method-post { background: #f59e0b; }
.method-get { background: #22c55e; }
.endpoint-path {
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 12px;
  background: #f3f4f6;
  padding: 3px 8px;
  border-radius: 4px;
  color: #374151;
}

/* ========== 系统设置开关 ========== */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #d1d5db; border-radius: 999px; transition: background .25s;
}
.switch-slider::before {
  content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .25s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .switch-slider { background: var(--primary); }
.switch input:checked + .switch-slider::before { transform: translateX(20px); }
.switch input:disabled + .switch-slider { opacity: .55; cursor: not-allowed; }
.switch input:disabled + .switch-slider::before { box-shadow: none; }

.settings-save-msg { font-size: 13px; color: var(--text-light); }
#btn-save-settings:disabled { opacity: .6; cursor: not-allowed; }
.settings-card-body input:disabled, .settings-card-body select:disabled {
  background: #f9fafb; color: #9ca3af; cursor: not-allowed;
}
.settings-card-note code { background: #f3f4f6; padding: 1px 5px; border-radius: 4px; font-size: 12px; color: #374151; }

/* ========== 首页设置 & 活动风采（资讯）========== */
.settings-card-sub { font-size: 12px; color: var(--text-light); }
.img-upload-row { display: flex; align-items: flex-start; gap: 14px; }
.img-upload-row input[type="text"] { width: 100%; }
.img-preview { display: inline-block; object-fit: contain; background: #f9fafb; }
.news-thumb { width: 84px; height: 50px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.modal-dialog.modal-lg { width: 860px; }
.badge-ok { background: #dcfce7; color: #166534; padding: 3px 10px; border-radius: 999px; font-size: 12px; }
.badge-warn { background: #fef3c7; color: #92400e; padding: 3px 10px; border-radius: 999px; font-size: 12px; }
.btn-mini {
  padding: 5px 12px;
  font-size: 13px;
  background: #eef1fe;
  color: #4f6df5;
  border: 1px solid #c7d2fe;
  border-radius: 6px;
  cursor: pointer;
  transition: background .2s;
}
.btn-mini:hover { background: #e0e6fe; }
.btn-mini-danger { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.btn-mini-danger:hover { background: #fee2e2; }
.news-para {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
  background: #fafbfc;
}
.news-para-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.news-para-index { font-size: 13px; font-weight: 600; color: var(--text-main); }
.news-para-text { width: 100%; margin-bottom: 8px; }
.news-para-img-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.news-para-img { flex: 1; min-width: 200px; }
.news-para-preview {
  max-height: 70px;
  max-width: 120px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin-left: 6px;
}

/* ===== 延时课堂（图片管理） ===== */
.gallery-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.gallery-admin-card {
  position: relative;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.gallery-admin-card img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
}
.gallery-admin-card.img-broken img {
  display: none;
}
.gallery-admin-card-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-light, #888);
}
.gallery-admin-card-no {
  font-weight: 600;
  color: var(--text-main, #333);
}
.gallery-admin-card .btn-mini-danger {
  position: absolute;
  top: 6px;
  right: 6px;
}
.gallery-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 0;
  color: var(--text-light, #888);
}
