/* ============= 全局重置与基础 ============= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f5f7fa;
  color: #2c3e50;
  font-size: 14px;
  line-height: 1.6;
}

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

.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

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

.logo-icon {
  font-size: 56px;
  display: block;
  margin-bottom: 10px;
}

.logo-icon.small {
  font-size: 32px;
}

.app-title {
  font-size: 24px;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 5px;
}

.app-subtitle {
  font-size: 14px;
  color: #7f8c8d;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: #34495e;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  background: #fff;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-primary {
  padding: 12px 24px;
  background: #667eea;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 8px;
}

.btn-primary:hover {
  background: #5568d3;
}

.btn-primary:disabled {
  background: #b0b8d8;
  cursor: not-allowed;
}

.btn-secondary {
  padding: 8px 18px;
  background: #fff;
  color: #34495e;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  border-color: #999;
  background: #fafafa;
}

.btn-danger {
  padding: 8px 18px;
  background: #e74c3c;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

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

.btn-success {
  padding: 8px 18px;
  background: #27ae60;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-success:hover {
  background: #1e8449;
}

.btn-small {
  padding: 6px 12px;
  font-size: 13px;
}

.error-message {
  color: #e74c3c;
  font-size: 13px;
  padding: 8px 12px;
  background: #fef5f5;
  border-radius: 6px;
  border-left: 3px solid #e74c3c;
}

.success-message {
  color: #27ae60;
  font-size: 13px;
  padding: 8px 12px;
  background: #f1f9f4;
  border-radius: 6px;
  border-left: 3px solid #27ae60;
}

.login-tip {
  text-align: center;
  margin-top: 20px;
  font-size: 12px;
  color: #95a5a6;
}

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

.sidebar {
  width: 220px;
  background: #2c3e50;
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #3d5a7a;
}

.logo-text {
  font-size: 16px;
  font-weight: 600;
}

.sidebar-nav {
  flex: 1;
  padding: 15px 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: #bdc3c7;
  text-decoration: none;
  font-size: 14px;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: #34495e;
  color: #fff;
}

.nav-item.active {
  background: #34495e;
  color: #fff;
  border-left-color: #667eea;
}

.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 15px 20px;
  border-top: 1px solid #3d5a7a;
}

.user-info {
  margin-bottom: 10px;
  font-size: 13px;
  color: #bdc3c7;
}

.btn-logout {
  width: 100%;
  padding: 8px;
  background: #34495e;
  color: #bdc3c7;
  border: 1px solid #3d5a7a;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: #e74c3c;
  color: #fff;
  border-color: #e74c3c;
}

/* ============= 主内容区 ============= */
.main-content {
  margin-left: 220px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.top-bar {
  background: #fff;
  padding: 20px 30px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-title {
  font-size: 20px;
  font-weight: 600;
  color: #2c3e50;
}

.view-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.view-content {
  padding: 30px;
  flex: 1;
}

/* ============= 数据卡片 ============= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-card .label {
  font-size: 13px;
  color: #7f8c8d;
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 32px;
  font-weight: 600;
  color: #2c3e50;
}

.stat-card .unit {
  font-size: 14px;
  color: #7f8c8d;
  margin-left: 4px;
}

.stat-card .icon {
  font-size: 32px;
  margin-bottom: 12px;
  display: block;
}

.stats-section {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.stats-section h3 {
  font-size: 16px;
  margin-bottom: 16px;
  color: #2c3e50;
}

.stats-grid-small {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.stat-mini {
  padding: 14px;
  background: #f8f9fc;
  border-radius: 8px;
}

.stat-mini .label {
  font-size: 12px;
  color: #7f8c8d;
}

.stat-mini .value {
  font-size: 22px;
  font-weight: 600;
  color: #2c3e50;
  margin-top: 4px;
}

/* ============= 表格 ============= */
.card {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  margin-bottom: 20px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 16px;
}

.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

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

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

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

thead {
  background: #f8f9fc;
}

th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  color: #34495e;
  border-bottom: 2px solid #e5e7eb;
  white-space: nowrap;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid #ecf0f1;
  color: #2c3e50;
  vertical-align: middle;
}

tbody tr:hover {
  background: #f8f9fc;
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.action-link {
  color: #667eea;
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
}

.action-link:hover {
  text-decoration: underline;
}

.action-link.danger {
  color: #e74c3c;
}

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

.status-tag.active {
  background: #d4efdf;
  color: #27ae60;
}

.status-tag.inactive {
  background: #fadbd8;
  color: #e74c3c;
}

.status-tag.info {
  background: #d6eaf8;
  color: #2980b9;
}

.status-tag.admin {
  background: #f5eef8;
  color: #8e44ad;
}

/* ============= 分页 ============= */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #ecf0f1;
}

.pagination-info {
  font-size: 13px;
  color: #7f8c8d;
}

.pagination-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.page-btn {
  padding: 6px 12px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.page-btn:hover:not(:disabled) {
  border-color: #667eea;
  color: #667eea;
}

.page-btn.active {
  background: #667eea;
  color: #fff;
  border-color: #667eea;
}

.page-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============= Toast ============= */
.toast {
  position: fixed;
  top: 30px;
  right: 30px;
  padding: 14px 20px;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  animation: slideIn 0.3s ease;
  max-width: 320px;
}

.toast.success {
  background: #27ae60;
}

.toast.error {
  background: #e74c3c;
}

.toast.info {
  background: #3498db;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ============= 模态框 ============= */
.modal-backdrop {
  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: 200;
  padding: 20px;
}

.modal {
  background: #fff;
  border-radius: 10px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

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

.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: #2c3e50;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: #95a5a6;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-close:hover {
  color: #e74c3c;
}

.modal-body {
  padding: 24px;
}

.modal-form {
  display: grid;
  gap: 16px;
}

.modal-form .form-group input,
.modal-form .form-group select,
.modal-form .form-group textarea {
  width: 100%;
}

.modal-form textarea {
  min-height: 100px;
  resize: vertical;
  font-family: inherit;
}

.modal-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid #ecf0f1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ============= 用户信息展示 ============= */
.user-detail {
  display: grid;
  gap: 12px;
}

.detail-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  padding: 10px 0;
  border-bottom: 1px solid #ecf0f1;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  color: #7f8c8d;
  font-size: 13px;
}

.detail-value {
  color: #2c3e50;
  font-size: 14px;
  font-weight: 500;
}

/* ============= 加载状态 ============= */
.loading {
  text-align: center;
  padding: 40px;
  color: #7f8c8d;
  font-size: 14px;
}

.loading::before {
  content: "";
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid #ecf0f1;
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 12px;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #95a5a6;
}

.empty-state .icon {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state .text {
  font-size: 14px;
}

/* ============= 响应式 ============= */
@media (max-width: 768px) {
  .sidebar {
    width: 60px;
  }
  .logo-text,
  .nav-item span:not(.nav-icon),
  .user-info {
    display: none;
  }
  .nav-item {
    justify-content: center;
    padding: 12px;
  }
  .main-content {
    margin-left: 60px;
  }
  .modal-form-row {
    grid-template-columns: 1fr;
  }
}
