/* 美播分销渠道管理平台 - 全局样式 */
/* 风格：深蓝 + 金色 商务主题 */
:root {
  --primary: #1a3c6e;
  --primary-light: #2563a8;
  --primary-hover: #122d56;
  --accent: #c9a227;
  --accent-hover: #b08a1e;
  --danger: #e53935;
  --success: #43a047;
  --warning: #fb8c00;
  --info: #1565c0;
  --text-primary: #1a2340;
  --text-secondary: #7b8aa0;
  --text-light: #b0bec5;
  --border: #dde3ed;
  --bg: #f0f3f8;
  --bg-white: #ffffff;
  --bg-card: #ffffff;
  --sidebar-bg: linear-gradient(175deg, #0d2240 0%, #1a3c6e 100%);
  --sidebar-text: #aec6e8;
  --sidebar-active-bg: rgba(201,162,39,0.15);
  --sidebar-active-text: #c9a227;
  --sidebar-hover-bg: rgba(255,255,255,0.06);
  --header-height: 60px;
  --sidebar-width: 228px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 12px rgba(26,60,110,.08);
  --shadow-md: 0 4px 20px rgba(26,60,110,.12);
}

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

html, body { width: 100%; height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg);
  min-height: 100vh;
}

a { text-decoration: none; color: var(--primary-light); }
ul, ol { list-style: none; }

/* ===== 布局 ===== */
.layout { display: flex; min-height: 100vh; width: 100%; overflow-x: hidden; }

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
  box-shadow: 3px 0 16px rgba(13,34,64,.18);
}

.sidebar-logo {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 20px;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,.08);
  white-space: nowrap;
  overflow: hidden;
  letter-spacing: .5px;
}

.sidebar-logo .logo-icon {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  margin-right: 10px;
  flex-shrink: 0;
}

.sidebar-logo .logo-text { line-height: 1.2; }
.sidebar-logo .logo-text .logo-sub { font-size: 11px; font-weight: 400; color: var(--sidebar-text); margin-top: 1px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 4px; }

.nav-group-title {
  width: calc(100% - 16px);
  margin: 0 8px;
  background: transparent;
  border: 0;
  font-size: 11px;
  color: rgba(174,198,232,.45);
  padding: 14px 12px 5px;
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: default;
  text-align: left;
}

.nav-group-items { overflow: hidden; }
.nav-group-arrow { display: none; font-size: 11px; transition: transform .2s; }

.nav-item {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  cursor: pointer;
  color: var(--sidebar-text);
  transition: all .18s;
  border-radius: 0;
  margin: 1px 8px;
  border-radius: 8px;
  gap: 10px;
  position: relative;
}

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

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
  left: 0;
}

.nav-icon { font-size: 16px; flex-shrink: 0; width: 20px; text-align: center; }
.nav-label { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item-home { margin-top: 2px; margin-bottom: 8px; }

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  color: rgba(174,198,232,.5);
  font-size: 11px;
  text-align: center;
}

/* ===== Header ===== */
.main { margin-left: var(--sidebar-width); display: flex; flex-direction: column; min-height: 100vh; flex: 1; min-width: 0; width: calc(100% - var(--sidebar-width)); }

.header {
  height: var(--header-height);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
  gap: 12px;
}

.header-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.header-user {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 8px;
  transition: background .15s;
}

.header-user:hover { background: var(--bg); }

.avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ===== Content ===== */
.content {
  flex: 1;
  padding: 20px 24px;
  overflow: auto;
}

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title::before {
  content: '';
  display: block;
  width: 3px; height: 16px;
  background: var(--accent);
  border-radius: 2px;
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .18s;
  white-space: nowrap;
  text-decoration: none;
}

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

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

.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline:hover { background: rgba(26,60,110,.06); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { background: #c62828; border-color: #c62828; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg); color: var(--text-primary); }

.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-xs { padding: 2px 8px; font-size: 12px; }

/* ===== 表单 ===== */
.form-item { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 5px;
}
.form-label.required::after { content: ' *'; color: var(--danger); }
.form-hint { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

.input, .select, textarea.input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-white);
  outline: none;
  transition: border-color .18s, box-shadow .18s;
  appearance: none;
  -webkit-appearance: none;
}

textarea.input { height: auto; padding: 8px 12px; resize: vertical; }

.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(37,99,168,.1);
}

.input-group { display: flex; gap: 8px; align-items: center; }
.input-group .input { flex: 1; }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }

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

thead tr {
  background: #f5f7fc;
  border-bottom: 1px solid var(--border);
}

thead th {
  padding: 11px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  font-size: 12px;
  letter-spacing: .3px;
}

tbody tr {
  border-bottom: 1px solid #eef0f5;
  transition: background .12s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8faff; }

tbody td {
  padding: 11px 14px;
  color: var(--text-primary);
  vertical-align: middle;
}

/* ===== 筛选栏 ===== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 14px 18px;
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.filter-bar .input, .filter-bar .select { height: 34px; width: auto; min-width: 140px; }
.filter-bar .btn { height: 34px; }

/* ===== 分页 ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 14px 0 0;
  flex-wrap: wrap;
}
.page-info { font-size: 13px; color: var(--text-secondary); margin-right: 8px; }
.page-btn {
  min-width: 32px; height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  background: var(--bg-white);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all .15s;
  display: inline-flex; align-items: center; justify-content: center;
}
.page-btn:hover:not(:disabled) { border-color: var(--primary-light); color: var(--primary-light); background: rgba(37,99,168,.04); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ===== 徽章 ===== */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: #e8f5e9; color: #2e7d32; }
.badge-danger  { background: #fce4ec; color: #c62828; }
.badge-warning { background: #fff3e0; color: #e65100; }
.badge-info    { background: #e3f2fd; color: #1565c0; }
.badge-default { background: #f0f3f8; color: #7b8aa0; }
.badge-gold    { background: #fff8e1; color: #c9a227; }

/* ===== 模态框 ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(13,34,64,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  backdrop-filter: blur(2px);
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(13,34,64,.18);
  width: 94vw;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: none; background: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.modal-close:hover { background: var(--bg); color: var(--danger); }

.modal-body { flex: 1; overflow-y: auto; padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 24px; right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  min-width: 220px;
  max-width: 340px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 4px 20px rgba(13,34,64,.16);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  animation: toastIn .25s ease;
  border-left: 3px solid var(--primary);
}
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
@keyframes toastIn { from { opacity:0; transform: translateX(30px); } to { opacity:1; transform: none; } }

/* ===== 登录页 ===== */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0d2240 0%, #1a3c6e 50%, #0d3060 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(201,162,39,.15) 0%, transparent 70%);
  top: -100px; right: -100px;
  border-radius: 50%;
}

.login-page::after {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(37,99,168,.2) 0%, transparent 70%);
  bottom: -50px; left: -50px;
  border-radius: 50%;
}

.login-card {
  background: rgba(255,255,255,.97);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  padding: 40px 36px;
  width: 420px;
  max-width: 94vw;
  position: relative;
  z-index: 1;
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo .logo-badge {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 32px;
  margin-bottom: 12px;
  box-shadow: 0 8px 24px rgba(26,60,110,.3);
}

.login-logo h1 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: .5px;
}

.login-logo .subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.login-divider {
  text-align: center;
  color: var(--text-secondary);
  font-size: 12px;
  margin: 16px 0;
  position: relative;
}
.login-divider::before, .login-divider::after {
  content: '';
  position: absolute;
  top: 50%; width: calc(50% - 30px);
  height: 1px; background: var(--border);
}
.login-divider::before { left: 0; }
.login-divider::after { right: 0; }

/* ===== 统计卡片 ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--bg-white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: box-shadow .18s, transform .18s;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.icon-blue { background: #e3f0ff; }
.icon-gold { background: #fff8e1; }
.icon-green { background: #e8f5e9; }
.icon-red { background: #fce4ec; }

.stat-info { flex: 1; min-width: 0; }
.stat-val { font-size: 24px; font-weight: 800; color: var(--text-primary); line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* ===== 移动端汉堡 ===== */
.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 24px; height: 18px;
  background: none; border: none; cursor: pointer; padding: 0;
}
.menu-toggle span { display: block; height: 2px; background: var(--text-primary); border-radius: 2px; transition: all .2s; }

.sidebar-mask {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 99;
}

/* ===== 二维码页面 ===== */
.qrcode-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 24px;
}
.qrcode-box {
  width: 220px; height: 220px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  background: #fff;
  padding: 10px;
}
.qrcode-box canvas { display: block; }

.invite-url-box {
  width: 100%;
  max-width: 440px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  word-break: break-all;
  color: var(--text-primary);
  border: 1px solid var(--border);
}

/* ===== 组织树 ===== */
.org-tree { padding: 8px 0; }
.org-node {
  cursor: pointer;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  transition: background .15s;
  border: 1px solid transparent;
}
.org-node:hover { background: #f0f5ff; border-color: #d0e0ff; }
.org-node.selected { background: #e8f0ff; border-color: var(--primary-light); font-weight: 600; }
.org-children { margin-left: 20px; border-left: 2px solid #dde3ed; padding-left: 12px; }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .main { margin-left: 0; width: 100%; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-mask.show { display: block; }
  .menu-toggle { display: flex; }
  .sidebar-nav { padding-top: 10px; }
  .nav-item { padding: 9px 14px; margin: 1px 6px; gap: 8px; }
  .nav-label { font-size: 12px; }
  .nav-group-title {
    cursor: pointer;
    padding: 12px 10px 4px;
    width: calc(100% - 12px);
    margin: 0 6px;
  }
  .nav-group-arrow { display: inline-block; transform: rotate(-90deg); }
  .nav-group .nav-group-items { display: none; }
  .nav-group.expanded .nav-group-items { display: block; }
  .nav-group.expanded .nav-group-arrow { transform: rotate(0deg); }
  .content { padding: 14px 12px; }
  .header { padding: 0 14px; }
  .filter-bar { padding: 10px 12px; }
  .filter-bar .input, .filter-bar .select { min-width: 120px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .hide-mobile { display: none !important; }
  .dash-grid { grid-template-columns: 1fr !important; }
}

/* ===== 卡片阴影变量补全 ===== */
:root {
  --card-shadow: 0 2px 12px rgba(26,60,110,.08);
}

/* ===== 页面标题栏 ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}
.page-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.page-home-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  transition: all .15s ease;
}
.page-home-link:hover {
  color: var(--primary);
  border-color: rgba(26,60,110,.22);
  background: #f7f9fd;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

@media (max-width: 768px) {
  .page-header { align-items: flex-start; }
  .page-header-actions { width: 100%; justify-content: flex-start; }
  .page-home-link { height: 34px; padding: 0 12px; }
  .table-wrap { overscroll-behavior-x: contain; }
  .table th, .table td { white-space: nowrap; }
}

/* ===== 搜索栏 ===== */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 14px 18px;
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.search-bar .input,
.search-bar .select { height: 34px; width: auto; }
.search-bar .btn { height: 34px; }

/* ===== 表格容器 ===== */
.table-wrap {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  position: relative;
}
.table {
  width: max-content;
  min-width: 100%;
}

/* ===== 行内操作按钮 ===== */
.btn-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 12px;
  cursor: pointer;
  color: var(--primary-light);
  transition: all .15s;
  margin: 0 2px;
  white-space: nowrap;
}
.btn-icon:hover { background: #eef3ff; border-color: var(--primary-light); }
.btn-icon.danger { color: var(--danger); border-color: #fcd8d8; }
.btn-icon.danger:hover { background: #fff0f0; border-color: var(--danger); }

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-secondary);
  font-size: 14px;
}
.empty-state::before {
  content: '📭';
  display: block;
  font-size: 40px;
  margin-bottom: 12px;
}

/* ===== Loading 遮罩 ===== */
.loading-mask {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: var(--radius);
}
.spinner {
  width: 30px; height: 30px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 标签蓝色 ===== */
.badge-blue { background: #e3f0ff; color: var(--primary); }
