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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: #f5f7fa;
  color: #333;
  font-size: 14px;
}

/* 登录页 */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
  background: white;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 400px;
}

.login-box h1 {
  text-align: center;
  color: #333;
  margin-bottom: 8px;
  font-size: 24px;
}

.login-box .subtitle {
  text-align: center;
  color: #999;
  margin-bottom: 30px;
  font-size: 14px;
}

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

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: #555;
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #667eea;
}

.btn {
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
}

.btn-primary {
  background: #667eea;
  color: white;
  width: 100%;
  padding: 12px;
  font-size: 16px;
}

.btn-primary:hover {
  background: #5a6fd8;
}

.btn-secondary {
  background: #f0f0f0;
  color: #333;
}

.btn-secondary:hover {
  background: #e0e0e0;
}

.btn-danger {
  background: #f56c6c;
  color: white;
}

.btn-danger:hover {
  background: #e85656;
}

.btn-success {
  background: #67c23a;
  color: white;
}

.btn-success:hover {
  background: #5db332;
}

.btn-warning {
  background: #e6a23c;
  color: white;
}

.btn-warning:hover {
  background: #d8942e;
}

.btn-danger {
  background: #dc2626;
  color: white;
  border: 1px solid #dc2626;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.error-message {
  color: #f56c6c;
  font-size: 13px;
  margin-top: 10px;
  text-align: center;
}

/* 主布局 */
.app-container {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: #1f2d3d;
  color: white;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid #2d3e50;
}

.sidebar-header h2 {
  font-size: 18px;
  color: white;
}

.sidebar-header .role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  margin-top: 6px;
}

.role-badge.admin {
  background: #f56c6c;
}

.role-badge.consultant {
  background: #67c23a;
}

.sidebar-menu {
  list-style: none;
  padding: 10px 0;
}

.sidebar-menu li {
  padding: 0;
}

.sidebar-menu a {
  display: block;
  padding: 12px 20px;
  color: #c0c4cc;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
  background: #2d3e50;
  color: white;
}

.sidebar-menu a.active {
  border-left: 3px solid #667eea;
  padding-left: 17px;
}

.main-content {
  flex: 1;
  margin-left: 220px;
  padding: 20px;
}

.topbar {
  background: white;
  padding: 15px 20px;
  border-radius: 8px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.topbar h1 {
  font-size: 18px;
  color: #333;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 15px;
}

.user-info .username {
  color: #666;
}

.user-info .logout-btn {
  color: #f56c6c;
  cursor: pointer;
  text-decoration: none;
}

.user-info .logout-btn:hover {
  text-decoration: underline;
}

.user-info .admin-entry-btn {
  color: #409eff;
  cursor: pointer;
  text-decoration: none;
  margin-right: 12px;
  padding: 4px 10px;
  border: 1px solid #409eff;
  border-radius: 4px;
  font-size: 13px;
}

.user-info .admin-entry-btn:hover {
  background: #409eff;
  color: white;
  text-decoration: none;
}

/* 卡片 */
.card {
  background: white;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #eee;
}

.card-header h2 {
  font-size: 16px;
  color: #333;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

th {
  background: #fafafa;
  font-weight: 600;
  color: #555;
  white-space: nowrap;
}

tr:hover {
  background: #f9f9f9;
}

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

.status-tag.active {
  background: #e7f5e7;
  color: #67c23a;
}

.status-tag.public_sea {
  background: #fff2e8;
  color: #e6a23c;
}

.status-tag.invalid {
  background: #fef0f0;
  color: #f56c6c;
}

.status-tag.pending {
  background: #ecf5ff;
  color: #409eff;
}

.status-tag.done {
  background: #f0f9eb;
  color: #67c23a;
}

/* 弹窗 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: white;
  border-radius: 8px;
  width: 500px;
  max-width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  padding: 15px 20px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 16px;
}

.modal-close {
  cursor: pointer;
  font-size: 20px;
  color: #999;
  border: none;
  background: none;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 15px 20px;
  border-top: 1px solid #eee;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* 搜索栏 */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-bar input,
.search-bar select {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}

.search-bar input {
  flex: 1;
  min-width: 200px;
}

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

.pagination button {
  padding: 6px 12px;
  border: 1px solid #ddd;
  background: white;
  border-radius: 4px;
  cursor: pointer;
}

.pagination button:hover {
  border-color: #667eea;
  color: #667eea;
}

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

.pagination .page-info {
  color: #666;
  font-size: 13px;
}

/* 统计卡片 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
}

.stat-card {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: bold;
  color: #667eea;
  margin-bottom: 5px;
}

.stat-card .stat-label {
  color: #999;
  font-size: 13px;
}

/* 提醒提示 */
.reminder-badge {
  display: inline-block;
  background: #f56c6c;
  color: white;
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 12px;
  margin-left: 5px;
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 40px;
  color: #999;
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 10px;
}

/* 详情信息 */
.detail-section {
  margin-bottom: 20px;
}

.detail-section h4 {
  margin-bottom: 10px;
  color: #333;
  font-size: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eee;
}

.detail-row {
  display: flex;
  padding: 8px 0;
  border-bottom: 1px solid #f5f5f5;
}

.detail-label {
  width: 100px;
  color: #999;
  flex-shrink: 0;
}

.detail-value {
  flex: 1;
  color: #333;
}

/* 跟进记录时间线 */
.timeline {
  position: relative;
  padding-left: 20px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #e0e0e0;
}

.timeline-item {
  position: relative;
  margin-bottom: 15px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #667eea;
}

.timeline-date {
  font-size: 12px;
  color: #999;
  margin-bottom: 4px;
}

.timeline-content {
  color: #333;
  font-size: 13px;
  line-height: 1.6;
}

/* 操作按钮组 */
.action-buttons {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

/* 警告提示 */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 15px;
}

.alert-warning {
  background: #fff7e6;
  border: 1px solid #ffd591;
  color: #d48806;
}

.alert-error {
  background: #fff2f0;
  border: 1px solid #ffccc7;
  color: #cf1322;
}

.alert-success {
  background: #f6ffed;
  border: 1px solid #b7eb8f;
  color: #389e0d;
}

/* Tab 切换 */
.tabs {
  display: flex;
  border-bottom: 2px solid #eee;
  margin-bottom: 20px;
}

.tab {
  padding: 10px 20px;
  cursor: pointer;
  color: #666;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.3s;
}

.tab:hover {
  color: #667eea;
}

.tab.active {
  color: #667eea;
  border-bottom-color: #667eea;
  font-weight: 500;
}

/* 文本域 */
textarea {
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
}

/* 表单行布局 */
.form-row {
  display: flex;
  gap: 15px;
}

.form-row .form-group {
  flex: 1;
}

/* ============================================
   移动端响应式适配
   ============================================ */

/* 移动端菜单按钮 */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1001;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  font-size: 20px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* 移动端遮罩 */
.mobile-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
}

.mobile-overlay.show {
  display: block;
}

/* 手机端（768px 以下） */
@media (max-width: 768px) {
  /* 登录页 */
  .login-container {
    padding: 20px;
    min-height: auto;
    padding-top: 60px;
  }
  .login-box {
    width: 100%;
    max-width: 100%;
    padding: 24px 20px;
  }
  .login-box h2 {
    font-size: 20px;
  }

  /* 侧边栏 - 手机端变成抽屉 */
  .mobile-menu-btn {
    display: flex;
  }
  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    bottom: 0;
    z-index: 1000;
    transition: left 0.3s ease;
    width: 240px;
  }
  .sidebar.show {
    left: 0;
  }
  .sidebar-header h2 {
    font-size: 16px;
  }
  .sidebar-menu a {
    padding: 10px 16px;
    font-size: 14px;
  }

  /* 主内容区 */
  .main-content {
    margin-left: 0;
    padding: 56px 12px 20px;
  }
  .header {
    padding: 10px 12px;
  }
  .header h1 {
    font-size: 18px;
    margin-left: 40px;
  }
  .header-actions {
    gap: 8px;
  }
  .header-actions .user-info span {
    display: none;
  }

  /* 卡片 */
  .card {
    border-radius: 10px;
  }
  .card-header {
    padding: 14px 16px;
  }
  .card-header h2 {
    font-size: 16px;
  }

  /* 统计卡片 */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .stat-card {
    padding: 14px 12px;
  }
  .stat-card .stat-value {
    font-size: 22px;
  }
  .stat-card .stat-label {
    font-size: 12px;
  }

  /* 表格 - 横向滚动 */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px;
    padding: 0 16px;
  }
  table {
    min-width: 600px;
    font-size: 13px;
  }
  th, td {
    padding: 10px 8px;
    white-space: nowrap;
  }
  .btn-sm {
    padding: 4px 8px;
    font-size: 12px;
  }

  /* 搜索筛选栏 */
  .filter-bar {
    flex-wrap: wrap;
    gap: 10px;
  }
  .filter-bar input,
  .filter-bar select {
    flex: 1;
    min-width: 120px;
  }

  /* 弹窗 */
  .modal {
    width: 95%;
    max-width: 95%;
    max-height: 90vh;
    margin: 5vh auto;
    border-radius: 12px;
  }
  .modal-header {
    padding: 14px 16px;
  }
  .modal-header h3 {
    font-size: 16px;
  }
  .modal-body {
    padding: 16px;
    max-height: calc(90vh - 120px);
    overflow-y: auto;
  }
  .modal-footer {
    padding: 12px 16px;
    gap: 10px;
  }

  /* 表单 */
  .form-group input,
  .form-group select,
  .form-group textarea {
    font-size: 16px; /* 防止 iOS 自动缩放 */
  }
  .form-row {
    flex-direction: column;
    gap: 10px;
  }

  /* 按钮 */
  .btn {
    padding: 8px 16px;
    font-size: 14px;
  }
  .btn-primary {
    padding: 10px 18px;
    font-size: 14px;
  }

  /* 时间线 */
  .timeline-item {
    padding: 10px 0 10px 24px;
  }
  .timeline-item::before {
    left: 6px;
    width: 10px;
    height: 10px;
  }

  /* 详情页 */
  .detail-row {
    flex-direction: column;
    gap: 4px;
  }
  .detail-label {
    min-width: auto;
    font-size: 12px;
    color: #999;
  }
  .detail-value {
    font-size: 14px;
  }
  .detail-section h4 {
    font-size: 15px;
  }

  /* 分页 */
  .pagination {
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
  }
  .page-btn {
    width: 32px;
    height: 32px;
    font-size: 13px;
  }

  /* 批量导入结果 */
  #importSummary {
    flex-wrap: wrap;
    gap: 10px;
  }
  #importSummary > div {
    flex: 1 1 calc(50% - 5px);
    min-width: calc(50% - 5px);
  }

  /* 公海列表 */
  .public-sea-actions {
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
  }
}

/* 小屏手机（480px 以下） */
@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .stat-card .stat-value {
    font-size: 20px;
  }
  .header h1 {
    font-size: 16px;
  }
  .card-header {
    flex-wrap: wrap;
    gap: 10px;
  }
  .filter-bar {
    flex-direction: column;
  }
  .filter-bar input,
  .filter-bar select {
    width: 100%;
  }
}

/* 横屏平板 */
@media (min-width: 769px) and (max-width: 1024px) {
  .sidebar {
    width: 200px;
  }
  .main-content {
    margin-left: 200px;
  }
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
