/* =============================================================================
   《英语加速器》运营管理后台 · 样式
   -----------------------------------------------------------------------------
   设计 Token 与产品主品牌保持一致（见 ui-design/UIDESIGN.md）：
     主色 #1E3A5F（深蓝）  辅色 #FF6B35（活力橙）  圆角 16  8pt 栅格
   本后台为桌面端管理界面，栅格沿用但字号略作收敛以保证信息密度。
   ========================================================================== */

:root {
  /* 品牌色 */
  --primary:        #1E3A5F;
  --primary-hover:  #2A4E7C;
  --primary-soft:   #E8EEF5;
  --accent:         #FF6B35;
  --accent-soft:    rgba(255, 107, 53, 0.12);

  /* 语义色 */
  --success:        #2ECC71;
  --success-soft:   rgba(46, 204, 113, 0.14);
  --error:          #E74C3C;
  --error-soft:     rgba(231, 76, 60, 0.12);
  --warning:        #F39C12;
  --warning-soft:   rgba(243, 156, 18, 0.14);
  --info:           #3498DB;
  --info-soft:      rgba(52, 152, 219, 0.12);

  /* 中性色 */
  --bg:             #F8F9FA;
  --surface:        #FFFFFF;
  --surface-alt:    #EEF1F5;
  --title:          #2C3E50;
  --sub:            #7F8C8D;
  --line:           #EAECEF;

  /* 尺寸 */
  --radius:         16px;
  --radius-sm:     10px;
  --radius-xs:     6px;
  --sidebar-w:     232px;
  --topbar-h:      60px;

  /* 阴影 */
  --shadow-sm:      0 1px 3px rgba(28, 44, 66, 0.06);
  --shadow:         0 2px 10px rgba(28, 44, 66, 0.08);
  --shadow-lg:      0 8px 32px rgba(28, 44, 66, 0.14);

  /* 过渡 */
  --t:             160ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ------------------------------------------------------------------ 基础重置 */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: system-ui, -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--title);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E0; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #A0AEC0; }

/* ================================================================= 登录页 */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #1E3A5F 0%, #2A4E7C 55%, #35608F 100%);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
}

.login-brand { text-align: center; margin-bottom: 32px; }

.login-logo {
  width: 56px; height: 56px;
  margin: 0 auto 16px;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  display: grid; place-items: center;
  font-size: 22px; font-weight: 700; letter-spacing: 0.5px;
}

.login-title { font-size: 20px; font-weight: 600; color: var(--title); }
.login-sub { font-size: 13px; color: var(--sub); margin-top: 4px; }

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

/* ------------------------------------------------------------------ 侧边栏 */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--primary);
  color: #CBDCEC;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
}

.sidebar-brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.sidebar-logo {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}

.sidebar-name { font-size: 15px; font-weight: 600; color: #fff; }
.sidebar-sub  { font-size: 11px; color: #8FB0CE; letter-spacing: 0.3px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }

.nav-group-label {
  padding: 14px 20px 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #6F93B8;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 20px;
  color: #CBDCEC;
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: background var(--t), color var(--t), border-color var(--t);
  cursor: pointer;
  user-select: none;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }

.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-left-color: var(--accent);
  font-weight: 500;
}

.nav-icon { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.sidebar-user { display: flex; align-items: center; gap: 10px; }

.sidebar-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  display: grid; place-items: center;
  font-size: 13px; font-weight: 600; color: #fff;
  flex-shrink: 0;
}

.sidebar-user-info { min-width: 0; flex: 1; }
.sidebar-user-name {
  font-size: 13px; color: #fff; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role { font-size: 11px; color: #8FB0CE; }

.btn-logout {
  background: none; border: none;
  color: #8FB0CE; padding: 4px;
  border-radius: var(--radius-xs);
  transition: color var(--t);
}
.btn-logout:hover { color: #fff; }

/* ------------------------------------------------------------------ 主区域 */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 20;
  flex-shrink: 0;
}

.topbar-title { font-size: 17px; font-weight: 600; color: var(--title); }
.topbar-desc  { font-size: 12px; color: var(--sub); margin-top: 1px; }

.topbar-right { display: flex; align-items: center; gap: 14px; }

.env-badge {
  padding: 4px 11px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: var(--success-soft);
  color: #1E8449;
}

.content { padding: 24px 28px 48px; flex: 1; }

/* ================================================================= 组件 */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.card-title { font-size: 15px; font-weight: 600; color: var(--title); }
.card-desc  { font-size: 12px; color: var(--sub); margin-top: 2px; }

/* ------------------------------------------------------------------ 指标卡 */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--primary);
}
.stat-card.accent::before { background: var(--accent); }
.stat-card.success::before { background: var(--success); }
.stat-card.warning::before { background: var(--warning); }

.stat-label { font-size: 12px; color: var(--sub); margin-bottom: 6px; }
.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--title);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.stat-unit { font-size: 14px; font-weight: 500; color: var(--sub); margin-left: 2px; }
.stat-meta { font-size: 12px; color: var(--sub); margin-top: 4px; }

/* ------------------------------------------------------------------ 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--t);
  white-space: nowrap;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover:not(:disabled) { background: #E85A28; }

.btn-outline {
  background: var(--surface);
  border-color: var(--line);
  color: var(--title);
}
.btn-outline:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }

.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #C0392B; }

.btn-ghost { background: none; color: var(--sub); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-alt); color: var(--title); }

.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: var(--radius-xs); }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ 表单 */
.form-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.form-field { display: flex; flex-direction: column; gap: 5px; min-width: 160px; }
.form-field.grow { flex: 1; }
.form-label { font-size: 12px; color: var(--sub); font-weight: 500; }

.input, .select, .textarea {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--title);
  font-size: 13px;
  transition: border-color var(--t), box-shadow var(--t);
  width: 100%;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.textarea { min-height: 90px; resize: vertical; font-family: inherit; }
.select { cursor: pointer; }

.checkbox { display: flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13px; }
.checkbox input { width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary); }

/* ------------------------------------------------------------------ 表格 */
.table-wrap { overflow-x: auto; margin: 0 -20px -20px; padding: 0 20px 20px; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }

.table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--sub);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: var(--surface-alt);
}

.table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--title);
  vertical-align: middle;
}

.table tbody tr { transition: background var(--t); }
.table tbody tr:hover { background: var(--primary-soft); }
.table tbody tr:last-child td { border-bottom: none; }

.table .num { font-variant-numeric: tabular-nums; }
.table .truncate { max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ------------------------------------------------------------------ 徽章 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-success { background: var(--success-soft); color: #1E8449; }
.badge-error   { background: var(--error-soft);   color: #C0392B; }
.badge-warning { background: var(--warning-soft); color: #B9770E; }
.badge-info    { background: var(--info-soft);    color: #21618C; }
.badge-neutral { background: var(--surface-alt);  color: var(--sub); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-accent  { background: var(--accent-soft);  color: #D35400; }

/* ------------------------------------------------------------------ 分页 */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.pagination-info { font-size: 12px; color: var(--sub); }
.pagination-controls { display: flex; gap: 6px; align-items: center; }

.page-btn {
  min-width: 32px; height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-xs);
  font-size: 13px;
  color: var(--title);
  transition: all var(--t);
}
.page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ------------------------------------------------------------------ 空态 / 加载 */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--sub);
}
.empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.35; }
.empty-text { font-size: 14px; }

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--sub);
  gap: 10px;
}

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ 提示条 */
.toast-wrap {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  border-left: 3px solid var(--primary);
  animation: slide-in 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
  font-size: 13px;
}

@keyframes slide-in {
  from { transform: translateX(calc(100% + 20px)); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--error); }
.toast.warning { border-left-color: var(--warning); }

.toast-icon { flex-shrink: 0; font-weight: 600; }
.toast.success .toast-icon { color: var(--success); }
.toast.error   .toast-icon { color: var(--error); }
.toast.warning .toast-icon { color: var(--warning); }
.toast-body { flex: 1; }

/* ------------------------------------------------------------------ 模态框 */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 32, 48, 0.5);
  backdrop-filter: blur(2px);
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 24px;
  animation: fade-in 160ms ease;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  animation: modal-in 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.modal.wide { max-width: 760px; }

@keyframes modal-in {
  from { transform: translateY(16px) scale(0.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title { font-size: 16px; font-weight: 600; }

.modal-close {
  background: none; border: none;
  font-size: 20px; color: var(--sub);
  line-height: 1; padding: 2px 6px;
  border-radius: var(--radius-xs);
}
.modal-close:hover { background: var(--surface-alt); color: var(--title); }

.modal-body { padding: 22px; overflow-y: auto; flex: 1; }

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* ------------------------------------------------------------------ 图表 */
.chart-box { width: 100%; height: 260px; }
.chart-box svg { width: 100%; height: 100%; display: block; }

.chart-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-size: 12px;
  color: var(--sub);
}

.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 9px; height: 9px; border-radius: 2px; }

/* ------------------------------------------------------------------ 进度条 */
.progress {
  height: 7px;
  background: var(--surface-alt);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 320ms ease;
}
.progress-bar.accent  { background: var(--accent); }
.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }

/* ------------------------------------------------------------------ 开关 */
.switch {
  position: relative;
  width: 40px; height: 22px;
  background: #CBD5E0;
  border-radius: 11px;
  border: none;
  transition: background var(--t);
  flex-shrink: 0;
}
.switch.on { background: var(--success); }

.switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--t);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.switch.on::after { transform: translateX(18px); }

/* ------------------------------------------------------------------ 筛选栏 */
.filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 16px 20px;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

/* ------------------------------------------------------------------ 详情页 */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.detail-item { font-size: 13px; }
.detail-label { color: var(--sub); font-size: 12px; margin-bottom: 3px; }
.detail-value { color: var(--title); font-weight: 500; word-break: break-all; }

.code-block {
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 380px;
  overflow-y: auto;
  color: var(--title);
}

/* ------------------------------------------------------------------ 选项卡 */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  overflow-x: auto;
}

.tab {
  padding: 9px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--sub);
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--t);
  white-space: nowrap;
}

.tab:hover { color: var(--title); }
.tab.active { color: var(--primary); border-bottom-color: var(--accent); }

/* ------------------------------------------------------------------ 告警条 */
.alert {
  display: flex;
  gap: 11px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  align-items: flex-start;
}

.alert-warning { background: var(--warning-soft); color: #8A6100; }
.alert-info    { background: var(--info-soft);    color: #1A5490; }
.alert-error   { background: var(--error-soft);   color: #A93226; }
.alert-success { background: var(--success-soft); color: #196F3D; }

/* ------------------------------------------------------------------ 响应式 */
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); transition: transform var(--t); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .content { padding: 20px 16px 40px; }
  .topbar { padding: 0 16px; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}
