/* ==========================================================================
   TOPLEAD 商业控制台样式表 (专业深色侧边栏 + 100% 全宽平铺表格 + 模态管理弹窗)
   ========================================================================== */

:root {
  --admin-bg: #f8fafc;
  --admin-surface: #ffffff;
  --admin-sidebar-bg: #0f172a;
  --admin-sidebar-hover: #1e293b;
  --admin-sidebar-active: #1e293b;
  --admin-text: #0f172a;
  --admin-muted: #64748b;
  --admin-border: #e2e8f0;
  --admin-primary: #0284c7;
  --admin-primary-hover: #0369a1;
  --admin-success: #059669;
  --admin-warning: #d97706;
  --admin-danger: #dc2626;
  --font-mono: 'JetBrains Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--admin-bg);
  color: var(--admin-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ==========================================================================
   1. 整体两栏布局架构 (Sidebar + Workspace)
   ========================================================================== */
.admin-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* 左侧固定侧边栏 (240px) */
.admin-sidebar {
  width: 240px;
  min-width: 240px;
  max-width: 240px;
  background-color: var(--admin-sidebar-bg);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.08);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

/* 品牌头部 */
.sidebar-brand {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.brand-badge {
  font-size: 10px;
  font-weight: 700;
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(56, 189, 248, 0.4);
}

/* 租户信息卡片 */
.sidebar-tenant-card {
  margin: 14px 14px 8px 14px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}

.tenant-company-name {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tenant-role-tag {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  background: #0284c7;
  color: #ffffff;
}

/* 导航链接 */
.sidebar-nav {
  flex: 1;
  padding: 10px 12px;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  font-weight: 700;
  padding: 12px 10px 6px 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  margin-bottom: 2px;
  transition: all 0.15s ease;
}

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

.nav-item.active {
  background-color: var(--admin-sidebar-active);
  color: #38bdf8;
  font-weight: 700;
  border-left: 3px solid #38bdf8;
}

.nav-icon {
  font-size: 15px;
}

/* 侧边栏底部 */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-compact {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.user-avatar-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #0284c7;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.user-username-txt {
  font-size: 12.5px;
  font-weight: 600;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}

.btn-sidebar-logout {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #94a3b8;
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-sidebar-logout:hover {
  background: rgba(220, 38, 38, 0.2);
  color: #fca5a5;
  border-color: rgba(220, 38, 38, 0.5);
}

/* ============================================================
   2. 右侧全屏工作区 (Workspace)
   ============================================================ */
.admin-workspace {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* 顶部轻量 Topbar (56px) */
.admin-topbar {
  height: 56px;
  background-color: var(--admin-surface);
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-site-badge {
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

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

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background-color: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 9999px;
  color: #166534;
  font-size: 11.5px;
  font-weight: 600;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.3);
}

/* 工作区流式容器 (100% 宽度，自适应呼吸间距) */
.admin-fluid-container {
  padding: 24px;
  flex: 1;
  width: 100%;
}

.admin-view {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ============================================================
   3. 卡片与表格容器通用规范
   ============================================================ */
.card-box {
  background-color: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  overflow: hidden;
}

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

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

.metric-card {
  background-color: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  padding: 18px 20px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
}

.metric-title {
  font-size: 12.5px;
  color: var(--admin-muted);
  font-weight: 600;
  margin-bottom: 6px;
}

.metric-number {
  font-size: 26px;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--admin-text);
  line-height: 1.1;
  margin-bottom: 6px;
}

.metric-sub {
  font-size: 11.5px;
  color: #94a3b8;
}

/* 分析面板双栏栅格 */
.analytics-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

@media (max-width: 1100px) {
  .analytics-grid {
    grid-template-columns: 1fr;
  }
}

.panel-card {
  background-color: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  overflow: hidden;
}

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

.panel-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--admin-text);
}

.panel-sub {
  font-size: 11px;
  color: var(--admin-muted);
}

.panel-body {
  padding: 16px 18px;
}

/* 渠道表格与排名列表 */
.channel-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.channel-table th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--admin-border);
  color: var(--admin-muted);
  font-weight: 600;
}

.channel-table td {
  padding: 10px;
  border-bottom: 1px solid #f1f5f9;
}

.rank-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.rank-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 12.5px;
}

.rank-index {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background-color: #f1f5f9;
  color: #475569;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  margin-right: 8px;
}

.rank-count {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--admin-primary);
}

/* ============================================================
   4. 买家线索全宽流水表 & 租户全宽铺满表
   ============================================================ */
.leads-section {
  background-color: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  overflow: hidden;
}

.filter-toolbar {
  padding: 14px 18px;
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  background-color: #ffffff;
}

.filter-left, .filter-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-input {
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 13px;
  outline: none;
  width: 260px;
}

.filter-input:focus {
  border-color: var(--admin-primary);
}

.filter-select {
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
  background-color: #ffffff;
}

.leads-table-container {
  overflow-x: auto;
  width: 100%;
}

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

.leads-table th {
  background-color: #f8fafc;
  padding: 12px 14px;
  font-weight: 700;
  color: #475569;
  border-bottom: 1px solid var(--admin-border);
  white-space: nowrap;
}

.leads-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.leads-table tr:hover {
  background-color: #f8fafc;
}

/* 状态标签 */
.status-tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.status-new { background-color: #eff6ff; color: #1d4ed8; }
.status-contacted { background-color: #fef3c7; color: #b45309; }
.status-deal { background-color: #ecfdf5; color: #047857; }
.status-junk { background-color: #f1f5f9; color: #64748b; }

.site-badge {
  display: inline-block;
  background: #f1f5f9;
  color: #334155;
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

/* 按钮规范 */
.btn-admin {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: all 0.15s ease;
}

.btn-admin-primary {
  background-color: var(--admin-primary);
  color: #ffffff;
}
.btn-admin-primary:hover {
  background-color: var(--admin-primary-hover);
}

.btn-admin-success {
  background-color: var(--admin-success);
  color: #ffffff;
}
.btn-admin-success:hover {
  background-color: #047857;
}

.btn-admin-outline {
  background-color: transparent;
  border: 1px solid var(--admin-border);
  color: #334155;
}
.btn-admin-outline:hover {
  background-color: #f1f5f9;
}

.btn-action-small {
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid var(--admin-border);
  background: #ffffff;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-action-small:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.pagination-bar {
  padding: 12px 18px;
  border-top: 1px solid var(--admin-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  color: var(--admin-muted);
}

/* 弹窗中的快捷站点标签 */
.site-tags-helper {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.site-tag-chip {
  font-size: 11px;
  padding: 3px 8px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  color: #334155;
  cursor: pointer;
  font-family: var(--font-mono);
  transition: all 0.15s ease;
}

.site-tag-chip:hover {
  background: #e0f2fe;
  border-color: #38bdf8;
  color: #0284c7;
}

/* ============================================================
   5. 模态弹窗系统 (Modal Overlay)
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  background-color: #ffffff;
  border-radius: 10px;
  width: 100%;
  max-width: 600px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  animation: modalScaleIn 0.18s ease-out;
}

@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

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

.modal-body {
  padding: 20px;
  max-height: 80vh;
  overflow-y: auto;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: #334155;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.form-control:focus {
  border-color: var(--admin-primary);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.1);
}
