/* ========== Reset & Base ========== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #06b6d4;
  --primary-light: #22d3ee;
  --primary-dark: #0891b2;
  --primary-bg: #ecfeff;
  --secondary: #3b82f6;
  --secondary-bg: #eff6ff;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --info: #8b5cf6;
  --info-bg: #f5f3ff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --shadow-xl: 0 20px 25px rgba(0,0,0,0.1), 0 10px 10px rgba(0,0,0,0.04);
  --transition: 0.2s ease;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ========== Sidebar ========== */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: white;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--gray-100);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.875rem;
  border-radius: var(--radius-sm);
  color: var(--gray-600);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
}

.nav-item:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}

.nav-item.active {
  background: var(--primary-bg);
  color: var(--primary-dark);
  font-weight: 600;
}

.nav-item.active svg {
  color: var(--primary-dark);
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--gray-100);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
  color: white;
  flex-shrink: 0;
}

.avatar.user-avatar {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
}

.user-detail {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--gray-800);
}

.user-role {
  font-size: 0.75rem;
  color: var(--gray-500);
}

.data-actions {
  display: flex;
  gap: 0.375rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--gray-100);
}

.data-actions .btn {
  flex: 1;
  font-size: 0.72rem;
  padding: 0.3rem 0.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  white-space: nowrap;
}

/* ========== Main Content ========== */
.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 2rem;
  min-height: 100vh;
}

.page {
  display: none;
}

.page.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== Page Header ========== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--gray-500);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.date-badge {
  background: white;
  border: 1px solid var(--gray-200);
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--gray-600);
  font-weight: 500;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.125rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary-dark);
  color: white;
  border-color: var(--primary-dark);
}

.btn-primary:hover {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: white;
  color: var(--gray-700);
  border-color: var(--gray-300);
}

.btn-secondary:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.btn-danger:hover {
  background: #dc2626;
  box-shadow: var(--shadow-md);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-xs {
  padding: 0.2rem 0.5rem;
  font-size: 0.72rem;
  border-radius: 4px;
}

.breadcrumb {
  padding: 0 0 0.5rem 0;
}

.breadcrumb a {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition);
}

.breadcrumb a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.btn-outline {
  background: transparent;
  color: var(--primary-dark);
  border-color: var(--primary);
}

.btn-outline:hover {
  background: var(--primary-bg);
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  background: white;
  color: var(--gray-600);
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
}

.btn-icon:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}

.btn-icon.danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger);
}

.btn-icon.primary:hover {
  background: var(--primary-bg);
  color: var(--primary-dark);
  border-color: var(--primary);
}

/* ========== Stats Grid ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 1.5rem;
  border: 1px solid var(--gray-200);
  transition: all var(--transition);
  cursor: default;
}

.stat-card.clickable {
  cursor: pointer;
}

.stat-card.clickable:active {
  transform: scale(0.97);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-card.clickable:active:hover {
  transform: scale(0.97);
}

.stat-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon.primary { background: var(--primary-bg); color: var(--primary-dark); }
.stat-icon.success { background: var(--success-bg); color: var(--success); }
.stat-icon.warning { background: var(--warning-bg); color: var(--warning); }
.stat-icon.danger { background: var(--danger-bg); color: var(--danger); }
.stat-icon.info { background: var(--info-bg); color: var(--info); }

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--gray-500);
  margin-top: 0.25rem;
}

/* ========== Cards ========== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
}

.card-body {
  padding: 1.25rem 1.5rem;
}

/* ========== Recent List ========== */
.recent-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: all var(--transition);
  border-radius: var(--radius-sm);
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.recent-item:hover {
  background: var(--gray-50);
}

.recent-item:last-child {
  border-bottom: none;
}

.recent-item .contact-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  color: white;
  flex-shrink: 0;
}

.recent-item .info {
  flex: 1;
  margin-left: 0.75rem;
  min-width: 0;
}

.recent-item .info .name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--gray-800);
}

.recent-item .info .detail {
  font-size: 0.8rem;
  color: var(--gray-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-item .time {
  font-size: 0.75rem;
  color: var(--gray-400);
  white-space: nowrap;
}

/* Relation list items */
.relation-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--gray-100);
}

.relation-item:last-child {
  border-bottom: none;
}

.relation-item .connector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.relation-item .connector .name-link {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--primary-dark);
  cursor: pointer;
}

.relation-item .connector .name-link:hover {
  text-decoration: underline;
}

.relation-item .connector .arrow {
  color: var(--gray-400);
  font-size: 0.8rem;
}

/* ========== Table ========== */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 360px;
}

.search-box svg {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
}

.search-box input {
  width: 100%;
  padding: 0.6rem 0.875rem 0.6rem 2.5rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: inherit;
  transition: all var(--transition);
  background: white;
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(6,182,212,0.1);
}

/* Dashboard search bar */
.dashboard-search {
  margin-bottom: 1.25rem;
}
.dashboard-search .search-box {
  position: relative;
  max-width: none;
}
.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 50;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
  margin-top: 2px;
}
.search-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  cursor: pointer;
  font-size: 0.875rem;
  transition: background var(--transition);
  border-bottom: 1px solid var(--gray-100);
}
.search-item:last-child {
  border-bottom: none;
}
.search-item:hover {
  background: var(--gray-50);
}
.search-item.no-result {
  color: var(--gray-400);
  cursor: default;
  justify-content: center;
}
.search-item-name {
  font-weight: 600;
  color: var(--gray-800);
  white-space: nowrap;
}
.search-item-sub {
  color: var(--gray-500);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-item-badge {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  background: var(--gray-100);
  color: var(--gray-500);
  border-radius: 999px;
  white-space: nowrap;
}
.search-item-all {
  justify-content: center;
  color: var(--primary);
  font-weight: 600;
  border-top: 1px solid var(--gray-100);
}
.search-item-all:hover {
  background: rgba(6,182,212,0.05);
}

/* Search results page */
.search-results-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.search-result-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}
.search-result-card:hover {
  border-color: var(--primary);
  background: rgba(6,182,212,0.03);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.search-result-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}
.search-result-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.search-result-name {
  font-weight: 600;
  color: var(--gray-800);
  font-size: 0.95rem;
}
.search-result-detail {
  color: var(--gray-500);
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-result-tags {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.search-result-tags .tag {
  font-size: 0.72rem;
  padding: 0.1rem 0.5rem;
  background: var(--gray-100);
  color: var(--gray-600);
  border-radius: 999px;
}

.filter-group {
  display: flex;
  gap: 0.5rem;
}

.filter-group select {
  padding: 0.6rem 0.875rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: inherit;
  background: white;
  color: var(--gray-700);
  cursor: pointer;
  transition: all var(--transition);
}

.filter-group select:focus {
  outline: none;
  border-color: var(--primary);
}

.table-wrapper {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  text-align: left;
  padding: 0.875rem 0.75rem;
  font-weight: 600;
  color: var(--gray-500);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--gray-100);
  white-space: nowrap;
}

.data-table td {
  padding: 0.875rem 0.75rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: all var(--transition);
}

.data-table tbody tr:hover {
  background: var(--gray-50);
}

.data-table .contact-cell {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.data-table .cell-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.8rem;
  color: white;
  flex-shrink: 0;
}

.data-table .cell-name {
  font-weight: 600;
  color: var(--gray-800);
}

/* ========== Relation Badge ========== */
.relation-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

.relation-badge.同事 { background: #dbeafe; color: #1d4ed8; }
.relation-badge.朋友 { background: #d1fae5; color: #047857; }
.relation-badge.同学 { background: #fef3c7; color: #b45309; }
.relation-badge.家人 { background: #fce7f3; color: #be185d; }
.relation-badge.业务伙伴 { background: #e0e7ff; color: #4338ca; }
.relation-badge.师生 { background: #f3e8ff; color: #6b21a8; }
.relation-badge.上下级 { background: #fee2e2; color: #b91c1c; }
.relation-badge.前同事 { background: #e0f2fe; color: #0369a1; }
.relation-badge.老乡 { background: #fef3c7; color: #92400e; }
.relation-badge.合作伙伴 { background: #ccfbf1; color: #0f766e; }
.relation-badge.其他 { background: #f3f4f6; color: #4b5563; }

/* ========== Tags ========== */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 500;
  background: var(--gray-100);
  color: var(--gray-600);
  margin: 0.1rem 0.15rem;
}

/* ========== Empty State ========== */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray-400);
}

.empty-state h3 {
  margin-top: 1rem;
  font-size: 1.1rem;
  color: var(--gray-600);
}

.empty-state p {
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

/* ========== Graph ========== */
.graph-container {
  width: 100%;
  height: 600px;
  background: #fafbfc;
  position: relative;
}

.graph-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--gray-100);
  background: white;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.graph-legend {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.legend-label {
  font-size: 0.8rem;
  color: var(--gray-500);
  font-weight: 500;
}

.legend-dot {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--gray-600);
}

.legend-dot::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--legend-color, #ccc);
  display: inline-block;
}

.legend-shape-dot::before {
  border-radius: 2px;
}

.legend-shape-circle::before {
  border-radius: 50%;
}

.legend-sep {
  color: var(--gray-300);
  font-size: 0.8rem;
}

/* ========== Graph Tooltip ========== */
.vis-tooltip {
  padding: 0.6rem 0.8rem !important;
  border-radius: 8px !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15) !important;
  border: 1px solid var(--gray-200) !important;
  background: #fff !important;
  max-width: 280px !important;
  font-family: Inter, sans-serif !important;
}

.graph-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  max-width: 320px;
  position: relative;
}

.graph-search svg {
  flex-shrink: 0;
}

.graph-search input {
  flex: 1;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}

.graph-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}


.graph-search-dropdown {
  position: absolute;
  top: 100%;
  left: 2rem;
  right: 0;
  margin-top: 2px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  list-style: none;
  padding: 0;
  z-index: 100;
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #c4c4c4 #f5f5f5;
}
.graph-search-dropdown::-webkit-scrollbar {
  width: 6px;
}
.graph-search-dropdown::-webkit-scrollbar-track {
  background: #f5f5f5;
  border-radius: 3px;
}
.graph-search-dropdown::-webkit-scrollbar-thumb {
  background: #c4c4c4;
  border-radius: 3px;
}
.graph-search-dropdown::-webkit-scrollbar-thumb:hover {
  background: #a0a0a0;
}

.graph-search-dropdown li {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--gray-100);
  transition: background 0.15s;
}

.graph-search-dropdown li:last-child {
  border-bottom: none;
}

.graph-search-dropdown li:hover {
  background: var(--gray-50);
}

/* ==================== 表单自定义下拉框 ==================== */
.dropdown-wrapper {
  position: relative;
}

.form-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 2px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  list-style: none;
  padding: 0;
  z-index: 200;
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #c4c4c4 #f5f5f5;
}
.form-dropdown::-webkit-scrollbar {
  width: 6px;
}
.form-dropdown::-webkit-scrollbar-track {
  background: #f5f5f5;
  border-radius: 3px;
}
.form-dropdown::-webkit-scrollbar-thumb {
  background: #c4c4c4;
  border-radius: 3px;
}
.form-dropdown::-webkit-scrollbar-thumb:hover {
  background: #a0a0a0;
}
.form-dropdown li {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--gray-100);
  transition: background 0.15s;
}
.form-dropdown li:last-child {
  border-bottom: none;
}
.form-dropdown li:hover {
  background: var(--gray-50);
}

.graph-actions {
  display: flex;
  gap: 0.5rem;
}

/* ========== Modal ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 90%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.2s ease;
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal-sm {
  max-width: 420px;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--gray-800);
}

.modal-close {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--gray-400);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}

.modal-body {
  padding: 1.5rem;
}

/* ========== Form ========== */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-row-3 {
  grid-template-columns: 1fr 100px 1fr;
}

.form-row-address {
  grid-template-columns: 1fr 1fr 1fr 2fr;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--gray-700);
}

.form-group .required {
  color: var(--danger);
}

.section-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  margin: 0.5rem 0 -0.5rem 0;
  padding-bottom: 0.25rem;
  border-bottom: 2px solid var(--primary);
  letter-spacing: 0.02em;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  transition: all var(--transition);
  background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(6,182,212,0.1);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* ========== Detail Section ========== */
.detail-top-action {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--gray-100);
}

.detail-top-action .btn {
  font-size: 0.9rem;
  padding: 0.5rem 1.2rem;
}

.detail-section {
  margin-bottom: 1.5rem;
}

.detail-section h3 {
  font-size: 0.85rem;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--gray-100);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  font-size: 0.9rem;
}

.detail-row .label {
  color: var(--gray-500);
  flex-shrink: 0;
  margin-right: 1rem;
}

.detail-row .value {
  color: var(--gray-800);
  text-align: right;
  word-break: break-all;
}

.detail-relations-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.detail-relation-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.detail-relation-item .rel-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.detail-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* ========== Contact Relation Rows ========== */
.relation-rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.relation-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
}

.relation-row select,
.relation-row input.type-select {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font-size: 0.85rem;
  font-family: inherit;
  background: white;
  color: var(--gray-700);
  transition: border-color var(--transition);
}

.relation-row select:focus,
.relation-row input.type-select:focus {
  outline: none;
  border-color: var(--primary);
}

.relation-row .contact-select {
  flex: 1;
  min-width: 0;
}

.relation-row .type-select {
  width: 140px;
  flex-shrink: 0;
}

.relation-row .btn-remove-row {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 4px;
  border: 1px solid var(--gray-200);
  background: white;
  color: var(--gray-500);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  font-size: 1rem;
  line-height: 1;
}

.relation-row .btn-remove-row:hover {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger);
}

/* ========== Toast ========== */
.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: white;
  border-radius: var(--radius-sm);
  padding: 0.875rem 1.125rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 0.875rem;
  font-weight: 500;
  animation: slideIn 0.3s ease;
  border-left: 4px solid var(--success);
  min-width: 280px;
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.warning {
  border-left-color: var(--warning);
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ========== Hamburger Button (Mobile) ========== */
.hamburger-btn {
  display: none;
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 200;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--gray-200);
  background: white;
  color: var(--gray-700);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}
.hamburger-btn:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 99;
}

/* ========== Responsive ========== */
@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .hamburger-btn {
    display: flex;
  }
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-xl);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.active {
    display: block;
  }
  .main-content {
    margin-left: 0;
    padding: 3.5rem 1rem 1rem;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .form-row-address {
    grid-template-columns: 1fr 1fr;
  }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .search-box {
    max-width: none;
  }
  .filter-group {
    flex-wrap: wrap;
  }
  .page-header {
    flex-direction: column;
  }
  .graph-container {
    height: 400px;
  }
}

/* ========== 登录页面 ========== */
.login-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-overlay.hidden {
  display: none;
}
.login-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 40%, #0c4a6e 100%);
  overflow: hidden;
}
.login-particles {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(2px 2px at 20% 30%, rgba(6,182,212,0.3), transparent),
    radial-gradient(2px 2px at 50% 70%, rgba(59,130,246,0.3), transparent),
    radial-gradient(3px 3px at 70% 20%, rgba(6,182,212,0.2), transparent),
    radial-gradient(2px 2px at 40% 80%, rgba(139,92,246,0.2), transparent),
    radial-gradient(1px 1px at 90% 40%, rgba(6,182,212,0.4), transparent),
    radial-gradient(2px 2px at 10% 60%, rgba(59,130,246,0.3), transparent);
  animation: floatParticles 20s linear infinite;
}
@keyframes floatParticles {
  0% { transform: translateY(0) rotate(0deg); opacity: 0.5; }
  50% { transform: translateY(-20px) rotate(1deg); opacity: 0.8; }
  100% { transform: translateY(0) rotate(0deg); opacity: 0.5; }
}
.login-overlay::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(6,182,212,0.08) 0%, transparent 70%);
  top: -200px; left: -200px;
  border-radius: 50%;
  animation: pulse 8s ease-in-out infinite;
}
.login-overlay::after {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(59,130,246,0.08) 0%, transparent 70%);
  bottom: -150px; right: -150px;
  border-radius: 50%;
  animation: pulse 10s ease-in-out infinite reverse;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.15); opacity: 0.8; }
}
.login-card {
  position: relative;
  z-index: 1;
  background: rgba(255,255,255,0.04);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 3rem 2.5rem 2.5rem;
  width: 400px;
  max-width: 90vw;
  box-shadow: 0 25px 60px rgba(0,0,0,0.4);
  animation: slideUp 0.5s ease;
}
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.login-logo h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: white;
  margin-top: 0.75rem;
  letter-spacing: -0.5px;
}
.login-subtitle {
  color: rgba(255,255,255,0.5);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.login-field {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 0 0.875rem;
  transition: border-color 0.2s, background 0.2s;
}
.login-field:focus-within {
  border-color: var(--primary);
  background: rgba(255,255,255,0.1);
}
.login-field svg {
  flex-shrink: 0;
}
.login-field input {
  width: 100%;
  background: none;
  border: none;
  padding: 0.875rem 0.75rem;
  font-size: 0.9375rem;
  color: white;
  outline: none;
  font-family: inherit;
}
.login-field input::placeholder {
  color: rgba(255,255,255,0.3);
}
.toggle-pwd {
  background: none;
  border: none;
  color: rgba(255,255,255,0.35);
  cursor: pointer;
  padding: 0.25rem;
  flex-shrink: 0;
  transition: color 0.2s;
}
.toggle-pwd:hover {
  color: rgba(255,255,255,0.7);
}
.login-error {
  color: #fca5a5;
  font-size: 0.8125rem;
  text-align: center;
  min-height: 1.25rem;
  transition: all 0.2s;
}
.login-error.shake {
  animation: shake 0.4s ease;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.btn-login {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border: none;
  border-radius: 10px;
  padding: 0.875rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.5px;
  margin-top: 0.5rem;
  font-family: inherit;
}
.btn-login:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 25px rgba(6,182,212,0.35);
}
.btn-login:active {
  transform: translateY(0);
}
.btn-login.loading span {
  visibility: hidden;
}
.btn-login.loading {
  position: relative;
}
.btn-login.loading::after {
  content: '';
  position: absolute;
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  top: calc(50% - 10px);
  left: calc(50% - 10px);
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.login-hint {
  text-align: center;
  color: rgba(255,255,255,0.25);
  font-size: 0.75rem;
  margin-top: 1.25rem;
}

/* 退出按钮 */
.btn-logout {
  color: var(--danger) !important;
  border-color: var(--danger) !important;
}
.btn-logout:hover {
  background: var(--danger-bg) !important;
}

.btn-logout-top {
  color: var(--danger) !important;
  border-color: var(--danger) !important;
  margin-left: 4px;
}
.btn-logout-top:hover {
  background: var(--danger-bg) !important;
  color: var(--danger) !important;
}

@media (max-width: 480px) {
  .login-card {
    padding: 2rem 1.5rem;
    border-radius: 16px;
  }
}

/* ========== 修改密码弹窗 ========== */
.change-pwd-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.change-pwd-card {
  background: white;
  border-radius: 14px;
  padding: 2rem;
  width: 380px;
  max-width: 90vw;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
  animation: slideUp 0.3s ease;
}
.change-pwd-card h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  color: var(--gray-800);
}
.modal-row {
  margin-bottom: 1rem;
}
.modal-row label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: 0.375rem;
}
.modal-row input {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 0.9375rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.modal-row input:focus {
  border-color: var(--primary);
}
.change-pwd-error {
  color: var(--danger);
  font-size: 0.8125rem;
  min-height: 1.25rem;
  margin-bottom: 0.5rem;
}
.modal-btns {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--gray-200);
  color: var(--gray-700);
}
