/* ==========================================================================
   环球号铺 · 管理后台样式
   视觉风格：Element UI 经典中后台（深色侧边栏 + 白色顶栏 + 灰色内容区）
   纯静态 CSS，无任何外部字体 / CDN / 图标库依赖，图标一律内联 SVG。
   ========================================================================== */

:root {
  /* ---- 主题色 ---- */
  --el-primary: #409eff;
  --el-primary-hover: #66b1ff;
  --el-primary-active: #3a8ee6;
  --el-success: #67c23a;
  --el-warning: #e6a23c;
  --el-danger: #f56c6c;
  --el-info: #909399;

  /* ---- 文字 ---- */
  --text-primary: #303133;
  --text-regular: #606266;
  --text-secondary: #909399;
  --text-placeholder: #c0c4cc;

  /* ---- 边框 ---- */
  --border-base: #dcdfe6;
  --border-light: #ebeef5;
  --border-lighter: #f2f6fc;

  /* ---- 背景 ---- */
  --bg-page: #f0f2f5;
  --bg-white: #ffffff;
  --bg-table-head: #fafafa;
  --bg-row-hover: #f5f7fa;

  /* ---- 侧边栏 ---- */
  --sidebar-bg: #304156;
  --sidebar-hover: #263445;
  --sidebar-text: #bfcbd9;
  --sidebar-width: 210px;
  --sidebar-collapsed-width: 64px;

  --radius: 4px;
  --shadow-card: 0 2px 12px 0 rgba(0, 0, 0, .1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", Arial, sans-serif;

  /* 兼容旧变量名（历史页面的内联样式可能引用） */
  --text: var(--text-primary);
  --text-2: var(--text-regular);
  --text-3: var(--text-secondary);
  --border: var(--border-base);
  --bg: var(--bg-page);
  --card: var(--bg-white);
  --primary: var(--el-primary);
  --green: var(--el-success);
  --red: var(--el-danger);
  --orange: var(--el-warning);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--el-primary); text-decoration: none; }

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

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   侧边栏
   ========================================================================== */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  transition: width .28s ease;
}

/* ---- 品牌区 ---- */
.sidebar .brand {
  height: 60px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  background: #2b3a4d;
  overflow: hidden;
}

.sidebar .brand .logo {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: var(--radius);
  background: var(--el-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar .brand .logo svg { width: 18px; height: 18px; }

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { color: #fff; font-size: 15px; font-weight: 600; line-height: 1.2; white-space: nowrap; }
.brand-sub { color: var(--el-info); font-size: 11px; line-height: 1.4; white-space: nowrap; }

/* ---- 菜单 ---- */
.sidebar nav {
  flex: 1;
  padding: 8px 0;
}

.sidebar nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 0 20px;
  color: var(--sidebar-text);
  font-size: 14px;
  white-space: nowrap;
  transition: background .2s, color .2s;
}

.sidebar nav a svg { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar nav a:hover { background: var(--sidebar-hover); color: #fff; }

.sidebar nav a.active {
  background: var(--sidebar-hover);
  color: var(--el-primary);
}

/* 选中项左侧 3px 蓝色指示条 */
.sidebar nav a.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--el-primary);
}

.nav-text { overflow: hidden; text-overflow: ellipsis; }

/* ---- 底部退出登录 ---- */
.sidebar .logout {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 50px;
  padding: 0 20px;
  flex-shrink: 0;
  color: var(--sidebar-text);
  font-size: 14px;
  border-top: 1px solid rgba(255, 255, 255, .06);
  white-space: nowrap;
  transition: background .2s, color .2s;
}

.sidebar .logout svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar .logout:hover { background: var(--sidebar-hover); color: var(--el-danger); }

/* ---- 折叠态（仅桌面端） ---- */
@media (min-width: 769px) {
  .layout.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed-width); }
  .layout.sidebar-collapsed .brand-text,
  .layout.sidebar-collapsed .nav-text { display: none; }
  .layout.sidebar-collapsed .sidebar .brand { justify-content: center; padding: 0; }
  .layout.sidebar-collapsed .sidebar nav a,
  .layout.sidebar-collapsed .sidebar .logout { justify-content: center; padding: 0; gap: 0; }
}

/* ==========================================================================
   顶部导航栏
   ========================================================================== */
.topbar {
  height: 60px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: var(--bg-white);
  border-bottom: 1px solid #e6e6e6;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-regular);
  cursor: pointer;
  transition: background .2s, color .2s;
}

.topbar-toggle:hover { background: var(--bg-row-hover); color: var(--el-primary); }
.topbar-toggle svg { width: 18px; height: 18px; }

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.breadcrumb .is-current { color: var(--text-primary); font-weight: 500; }
.breadcrumb .sep { color: var(--text-placeholder); }

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-user {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-regular);
  font-size: 14px;
}

.topbar-user svg { width: 16px; height: 16px; color: var(--text-secondary); }

.topbar-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius);
  color: var(--text-regular);
  font-size: 13px;
  transition: background .2s, color .2s;
}

.topbar-logout svg { width: 14px; height: 14px; }
.topbar-logout:hover { background: #fef0f0; color: var(--el-danger); }

/* ==========================================================================
   内容区
   ========================================================================== */
.content {
  flex: 1;
  min-width: 0;
  padding: 20px;
  background: var(--bg-page);
}

.page-head { margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 20px; font-weight: 600; color: var(--text-primary); }
.page-head .sub { margin-top: 4px; font-size: 13px; color: var(--text-secondary); }

/* ==========================================================================
   卡片
   ========================================================================== */
.card {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  margin-bottom: 20px;
  overflow: hidden;
}

.card:last-child { margin-bottom: 0; }

.card-header {
  height: 50px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-light);
}

/* 卡片头左侧蓝色竖条 */
.card-header-bar {
  width: 4px;
  height: 16px;
  margin-right: 10px;
  border-radius: 2px;
  background: var(--el-primary);
  flex-shrink: 0;
}

.card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body { padding: 20px; }

/* ==========================================================================
   数据统计卡片
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

@media (max-width: 1200px) { .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px)  { .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.stat {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 20px;
}

.stat .value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}

.stat .value.primary { color: var(--el-primary); }
.stat .value.green { color: var(--el-success); }
.stat .value.red { color: var(--el-danger); }
.stat .value.orange { color: var(--el-warning); }

.stat .label {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ==========================================================================
   筛选表单区
   ========================================================================== */
.filter-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
}

.filter-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  min-width: 0;
}

.filter-label {
  font-size: 13px;
  color: var(--text-regular);
  white-space: nowrap;
}

.filter-item input,
.filter-item select { width: 180px; }

.filter-range { display: flex; align-items: center; gap: 8px; }
.filter-range input { width: 150px; }
.filter-range .range-sep { color: var(--text-placeholder); }

.filter-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 账号筛选行的说明文字 */
.filter-hint { margin-top: 12px; font-size: 12px; color: var(--text-secondary); }

/* ==========================================================================
   表格
   ========================================================================== */
.table-wrap { overflow-x: auto; }

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

th {
  padding: 12px 14px;
  text-align: left;
  background: var(--bg-table-head);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-light);
}

td {
  padding: 12px 14px;
  color: var(--text-regular);
  vertical-align: middle;
  border-bottom: 1px solid var(--border-light);
}

tbody tr { transition: background .2s; }
tbody tr:hover { background: var(--bg-row-hover); }
tbody tr:last-child td { border-bottom: none; }

td.empty {
  padding: 40px 14px;
  text-align: center;
  color: var(--text-secondary);
}

/* 表格内的余额数字 */
td strong { color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ==========================================================================
   状态标签（.badge 为历史页面 JS 钩子名，.tag 为新版写法，视觉一致）
   ========================================================================== */
.badge,
.tag {
  display: inline-block;
  padding: 0 8px;
  height: 22px;
  line-height: 20px;
  font-size: 12px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  white-space: nowrap;
  vertical-align: middle;
}

.badge.green,   .tag.success { background: #f0f9eb; border-color: #e1f3d8; color: var(--el-success); }
.badge.red,     .tag.danger  { background: #fef0f0; border-color: #fde2e2; color: var(--el-danger); }
.badge.orange,  .tag.warning { background: #fdf6ec; border-color: #faecd8; color: var(--el-warning); }
.badge.blue,    .tag.primary { background: #ecf5ff; border-color: #d9ecff; color: var(--el-primary); }
.badge.gray,    .tag.info    { background: #f4f4f5; border-color: #e9e9eb; color: var(--el-info); }

/* ==========================================================================
   按钮
   ========================================================================== */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s, border-color .2s, color .2s;
}

button svg { width: 14px; height: 14px; }

.btn-primary { background: var(--el-primary); border-color: var(--el-primary); color: #fff; }
.btn-primary:hover { background: var(--el-primary-hover); border-color: var(--el-primary-hover); }
.btn-primary:active { background: var(--el-primary-active); border-color: var(--el-primary-active); }

.btn-ghost { background: #fff; border-color: var(--border-base); color: var(--text-regular); }
.btn-ghost:hover { background: #ecf5ff; border-color: #c6e2ff; color: var(--el-primary); }

.btn-danger { background: #fff; border-color: var(--border-base); color: var(--el-danger); }
.btn-danger:hover { background: #fef0f0; border-color: #fbc4c4; color: var(--el-danger); }

/* 表格 / 卡片头内的小按钮 */
.btn-sm { padding: 7px 15px; font-size: 12px; }
.btn-sm svg { width: 12px; height: 12px; }

button:disabled { opacity: .6; cursor: not-allowed; }

/* 表格内的文字操作链接 */
.link-primary { color: var(--el-primary); cursor: pointer; }
.link-primary:hover { color: var(--el-primary-hover); }
.link-danger { color: var(--el-danger); cursor: pointer; }
.link-danger:hover { color: #f78989; }
.link-sep { color: var(--border-base); margin: 0 6px; }

/* ==========================================================================
   表单
   ========================================================================== */
input, textarea, select {
  width: 100%;
  padding: 0 12px;
  height: 36px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-regular);
  background: #fff;
  border: 1px solid var(--border-base);
  border-radius: var(--radius);
  transition: border-color .2s;
}

textarea {
  height: auto;
  min-height: 100px;
  padding: 8px 12px;
  line-height: 1.5;
  resize: vertical;
}

select { padding-right: 8px; }

input::placeholder, textarea::placeholder { color: var(--text-placeholder); }

input:hover, textarea:hover, select:hover { border-color: #c0c4cc; }

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--el-primary);
}

input:disabled, textarea:disabled, select:disabled {
  background: #f5f7fa;
  color: var(--text-placeholder);
  cursor: not-allowed;
}

label {
  display: block;
  margin-bottom: 18px;
}

label > span, .field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text-regular);
}

label:last-child { margin-bottom: 0; }

/* 两列表单栅格（行距由 gap 控制，取消 label 自身下边距避免叠加） */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 20px;
}

.form-grid label { margin-bottom: 0; }

.form-hint { margin-top: 4px; font-size: 12px; color: var(--text-secondary); }

/* 群发消息 —— 按钮行 */
.btn-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.btn-row .btn-text { flex: 1; }
.btn-row .btn-url { flex: 2; }
.btn-row .remove-btn { flex-shrink: 0; }

/* 用户管理 —— 余额调整 */
.balance-adjust { display: flex; align-items: center; gap: 8px; }
.balance-adjust input { width: 110px; }

/* ==========================================================================
   提示信息
   ========================================================================== */
.msg {
  display: none;
  margin-top: 16px;
  padding: 10px 16px;
  font-size: 13px;
  border-radius: var(--radius);
}

.msg.ok  { display: block; background: #f0f9eb; border: 1px solid #e1f3d8; color: var(--el-success); }
.msg.err { display: block; background: #fef0f0; border: 1px solid #fde2e2; color: var(--el-danger); }
.msg.ok  a, .msg.err a { color: inherit; text-decoration: underline; }

/* ==========================================================================
   分页
   ========================================================================== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.pagination-info {
  margin-right: 4px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ==========================================================================
   表单底部操作条（设置页 / 群发页共用）
   ========================================================================== */
.form-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.form-footer .msg { margin-top: 0; flex: 1; }
.form-footer button { flex-shrink: 0; }

/* 窄内容页（群发消息） */
.card-narrow { max-width: 760px; }

/* ==========================================================================
   登录页
   ========================================================================== */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg-page);
}

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

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.login-brand .logo {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: var(--el-primary);
  color: #fff;
}

.login-brand .logo svg { width: 24px; height: 24px; }

.login-brand .name { font-size: 18px; font-weight: 600; color: var(--text-primary); }
.login-brand .sub { margin-top: 2px; font-size: 12px; color: var(--text-secondary); }

.login-error {
  display: none;
  margin-bottom: 16px;
  padding: 10px 14px;
  font-size: 13px;
  border-radius: var(--radius);
  background: #fef0f0;
  border: 1px solid #fde2e2;
  color: var(--el-danger);
}

.login-card .btn-primary { width: 100%; margin-top: 6px; }

/* ==========================================================================
   移动端遮罩
   ========================================================================== */
.nav-backdrop { display: none; }

/* ==========================================================================
   响应式（< 768px：侧边栏收起为抽屉，表格横向滚动）
   ========================================================================== */
@media (max-width: 768px) {
  .layout { display: block; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1200;
    width: var(--sidebar-width);
    height: 100vh;
    transform: translateX(-100%);
    transition: transform .28s ease;
  }

  body.nav-open .sidebar { transform: translateX(0); }

  .nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(0, 0, 0, .35);
  }

  body.nav-open .nav-backdrop { display: block; }

  .topbar { padding: 0 12px; gap: 10px; }
  .topbar-title { font-size: 15px; }
  .breadcrumb .crumb-root,
  .breadcrumb .sep { display: none; }
  .topbar-user .topbar-username { display: none; }

  .content { padding: 12px; }
  .stat { padding: 16px; }
  .stat .value { font-size: 22px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

  .card-body { padding: 16px; }
  .card-header { padding: 0 16px; }

  /* 筛选区改为竖排，控件占满整行 */
  .filter-form { flex-direction: column; align-items: stretch; gap: 12px; }
  .filter-item input,
  .filter-item select,
  .filter-range { width: 100%; }
  .filter-range input { width: 100%; min-width: 0; }
  .filter-actions { justify-content: flex-start; }

  /* 表单栅格降为单列 */
  .form-grid { grid-template-columns: minmax(0, 1fr); }

  /* 表格保持可读，超出横向滚动 */
  .table-wrap table { min-width: 720px; }

  .pagination { justify-content: space-between; }
  .form-footer { flex-direction: column; align-items: stretch; }
  .balance-adjust { min-width: 220px; }
}
