/* ==========================================================================
   Along Site · 管理后台样式 (M3)
   设计目标：专业 B2B SaaS 观感，桌面优先，兼容移动端，无多余装饰动画。
   ========================================================================== */

:root {
  --c-bg: #f5f7fa;
  --c-surface: #ffffff;
  --c-sidebar: #0f172a;
  --c-sidebar-hover: #1e293b;
  --c-sidebar-text: #cbd5e1;
  --c-border: #e2e8f0;
  --c-text: #0f172a;
  --c-text-muted: #64748b;
  --c-primary: #4f46e5;
  --c-primary-hover: #4338ca;
  --c-primary-soft: #eef2ff;
  --c-success: #059669;
  --c-warning: #d97706;
  --c-danger: #dc2626;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 18px 48px rgba(15, 23, 42, 0.18);
  --sidebar-w: 232px;
  --topbar-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
  font-size: 14px;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 550;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
  white-space: nowrap;
}

.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-hover); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--c-text-muted);
  border-color: var(--c-border);
}
.btn-ghost:hover { background: #f1f5f9; color: var(--c-text); }
.btn-ghost:disabled { opacity: .45; cursor: not-allowed; }

.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-icon { padding: 6px 10px; border-color: transparent; }

/* ------------------------------- 登录页 ------------------------------- */

.login-shell {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 500px at 50% -10%, #e0e7ff 0%, transparent 60%),
    var(--c-bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  padding: 32px 28px;
}

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

.login-brand h1 { font-size: 18px; letter-spacing: -.2px; }
.login-brand p { margin: 2px 0 0; font-size: 12.5px; color: var(--c-text-muted); }

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .5px;
  flex: 0 0 auto;
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field > span {
  display: block;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--c-text-muted);
  margin-bottom: 6px;
}

.field input,
.filter input,
.filter select {
  width: 100%;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--c-text);
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.field input:focus,
.filter input:focus,
.filter select:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}

.form-error {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-size: 12.5px;
}

.login-hint {
  margin: 18px 0 0;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--c-text-muted);
  text-align: center;
}

/* ------------------------------- 应用外壳 ------------------------------- */

.app-shell {
  display: flex;
  min-height: 100%;
}

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--c-sidebar);
  color: var(--c-sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 22px;
}

.sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.sidebar-brand-text strong { color: #fff; font-size: 14px; }
.sidebar-brand-text span { font-size: 11.5px; color: #94a3b8; }

.sidebar-nav { flex: 1; padding: 4px 10px; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--c-sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  transition: background-color .15s ease, color .15s ease;
}

.nav-item:hover { background: var(--c-sidebar-hover); color: #fff; }
.nav-item.active { background: var(--c-primary); color: #fff; }
.nav-item[data-coming] { opacity: .62; cursor: default; }
.nav-icon { width: 16px; text-align: center; opacity: .85; }

.nav-tag {
  margin-left: auto;
  font-size: 10px;
  font-style: normal;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(148, 163, 184, .18);
  color: #cbd5e1;
}

.sidebar-foot { padding: 14px 18px 18px; }
.env-badge {
  font-size: 10.5px;
  letter-spacing: .4px;
  padding: 3px 8px;
  border-radius: 5px;
  background: rgba(79, 70, 229, .22);
  color: #c7d2fe;
}

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

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

.topbar-left { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.topbar-left h2 { font-size: 16px; }

.scope-hint {
  font-size: 12px;
  color: var(--c-text-muted);
  padding: 2px 8px;
  border-radius: 5px;
  background: #f1f5f9;
  white-space: nowrap;
}

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

.user-chip { display: flex; align-items: center; gap: 9px; }

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--c-primary-soft);
  color: var(--c-primary);
  font-weight: 650;
  font-size: 12px;
}

.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-meta strong { font-size: 12.5px; }
.user-meta em { font-style: normal; font-size: 11px; color: var(--c-text-muted); }

.content { padding: 22px 24px 40px; }

/* ------------------------------- 筛选栏 ------------------------------- */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.filter { display: flex; flex-direction: column; gap: 5px; min-width: 130px; }
.filter > span { font-size: 11.5px; font-weight: 550; color: var(--c-text-muted); }
.filter-grow { flex: 1; min-width: 200px; }
.filter-actions { display: flex; gap: 8px; margin-left: auto; }

/* ------------------------------- 数据表格 ------------------------------- */

.table-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.table-scroll { overflow-x: auto; }

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

.data-table thead th {
  text-align: left;
  padding: 11px 14px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
  color: var(--c-text-muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}

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

.data-table tbody tr:hover { background: #fafbff; cursor: pointer; }
.data-table tbody tr:last-child td { border-bottom: none; }

.cell-primary { display: flex; flex-direction: column; gap: 2px; }
.cell-primary strong { font-weight: 600; font-size: 13px; }
.cell-primary span { font-size: 11.5px; color: var(--c-text-muted); }

.cell-muted { color: var(--c-text-muted); }
.cell-nowrap { white-space: nowrap; }
.empty-cell { text-align: center; padding: 42px 0 !important; color: var(--c-text-muted); }

.status-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

.status-new { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.status-contacted { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.status-qualified { background: #fefce8; color: #a16207; border-color: #fde68a; }
.status-quoted { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.status-closed_won { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.status-closed_lost { background: #f8fafc; color: #475569; border-color: #e2e8f0; }
.status-spam { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }

.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--c-border);
  background: #fcfdff;
}

.pagination-info { font-size: 12.5px; color: var(--c-text-muted); }
.pagination-controls { display: flex; align-items: center; gap: 10px; }
.page-indicator { font-size: 12.5px; color: var(--c-text-muted); min-width: 56px; text-align: center; }

/* ------------------------------- 抽屉 ------------------------------- */

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .38);
  z-index: 40;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 520px;
  max-width: 96vw;
  background: var(--c-surface);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--c-border);
}

.drawer-head h3 { font-size: 15px; }
.drawer-subtitle { display: block; margin-top: 3px; font-size: 12px; color: var(--c-text-muted); }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }

.section-label {
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--c-text-muted);
  margin: 22px 0 10px;
}
.section-label:first-child { margin-top: 0; }

.kv-grid {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 8px 12px;
  font-size: 13px;
}
.kv-grid dt { color: var(--c-text-muted); }
.kv-grid dd { margin: 0; word-break: break-word; }

.message-box {
  background: #f8fafc;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.status-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.status-chip-btn {
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--c-border);
  background: #fff;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  color: var(--c-text-muted);
  transition: all .15s ease;
}
.status-chip-btn:hover { border-color: var(--c-primary); color: var(--c-primary); }
.status-chip-btn.is-current {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: #fff;
  cursor: default;
}

.followup-form textarea {
  width: 100%;
  min-height: 74px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 13px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  resize: vertical;
  outline: none;
}
.followup-form textarea:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}

.followup-row { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.followup-row select {
  padding: 7px 10px;
  font-size: 12.5px;
  font-family: inherit;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: #fff;
}

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

.timeline li {
  position: relative;
  padding: 0 0 16px 20px;
  border-left: 2px solid #e2e8f0;
}
.timeline li:last-child { padding-bottom: 0; border-left-color: transparent; }

.timeline li::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-primary);
}

.timeline-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  font-size: 11.5px;
  color: var(--c-text-muted);
  margin-bottom: 3px;
}
.timeline-meta strong { font-size: 12.5px; color: var(--c-text); font-weight: 600; }

.timeline-content { font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }

.timeline-empty { font-size: 12.5px; color: var(--c-text-muted); padding: 8px 0; }

/* ------------------------------- Toast ------------------------------- */

.toast-host {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
}

.toast {
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #fff;
  background: #1e293b;
  box-shadow: var(--shadow-md);
  max-width: 340px;
}
.toast.is-error { background: #b91c1c; }
.toast.is-success { background: #047857; }

/* ------------------------------- 占位视图 ------------------------------- */

.placeholder-card {
  background: var(--c-surface);
  border: 1px dashed var(--c-border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  color: var(--c-text-muted);
  font-size: 13px;
}

/* ------------------------------- 响应式 ------------------------------- */

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 30;
    transform: translateX(-100%);
  }
  .sidebar.is-open { transform: translateX(0); }
  .main-area { width: 100%; }
  .filter-actions { margin-left: 0; width: 100%; }
  .drawer { width: 100vw; }
}

/* ==========================================================================
   M4：仪表盘 / 管理表单 / 域名弹窗
   ========================================================================== */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.stat-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
  color: var(--c-text-muted);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 26px;
  font-weight: 680;
  line-height: 1.1;
  letter-spacing: -.6px;
}

.stat-hint {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--c-text-muted);
}

.stat-card.is-accent { border-color: #c7d2fe; background: linear-gradient(180deg, #f8faff, #fff); }

.dash-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.panel {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--c-border);
}

.panel-head h3 { font-size: 13.5px; }
.panel-sub { font-size: 11.5px; color: var(--c-text-muted); }

.ranking-list { padding: 8px 16px 16px; }

.ranking-item { padding: 10px 0; border-bottom: 1px solid #f1f5f9; }
.ranking-item:last-child { border-bottom: none; }

.ranking-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  margin-bottom: 6px;
}
.ranking-top strong { font-weight: 600; }
.ranking-top span { color: var(--c-text-muted); font-size: 11.5px; }

.ranking-bar {
  height: 6px;
  border-radius: 999px;
  background: #f1f5f9;
  overflow: hidden;
}
.ranking-bar > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6366f1, #818cf8);
}

.recent-list { padding: 4px 0; }

.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
}
.recent-item:last-child { border-bottom: none; }
.recent-item:hover { background: #fafbff; }

.recent-main { min-width: 0; }
.recent-main strong { display: block; font-size: 12.5px; font-weight: 600; }
.recent-main span { font-size: 11.5px; color: var(--c-text-muted); }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.toolbar-title { font-size: 14px; }
.toolbar-actions { display: flex; gap: 8px; align-items: center; }
.toolbar-actions input {
  padding: 7px 11px;
  font-size: 12.5px;
  font-family: inherit;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  outline: none;
  min-width: 220px;
}

.form-panel {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.form-actions { display: flex; gap: 8px; margin-top: 14px; }

.mini-btn {
  padding: 4px 9px;
  font-size: 11.5px;
  font-family: inherit;
  border-radius: 5px;
  border: 1px solid var(--c-border);
  background: #fff;
  color: var(--c-text-muted);
  cursor: pointer;
}
.mini-btn:hover { border-color: var(--c-primary); color: var(--c-primary); }
.mini-btn.is-danger:hover { border-color: var(--c-danger); color: var(--c-danger); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .4);
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal {
  width: 100%;
  max-width: 520px;
  background: var(--c-surface);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--c-border);
}
.modal-head h3 { font-size: 14.5px; }
.modal-body { padding: 18px; max-height: 60vh; overflow-y: auto; }
.modal-foot {
  padding: 14px 18px;
  border-top: 1px solid var(--c-border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: #fcfdff;
}

.domain-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 12.5px;
}
.domain-row:last-child { border-bottom: none; }
.domain-name { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 600;
  background: #f1f5f9;
  color: #475569;
}
.tag.is-primary { background: #eef2ff; color: #4338ca; }

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