:root {
  --primary: #FF6B35;
  --primary-light: #FF9A5C;
  --primary-dark: #E55A2B;
  --bg: #F5F6FA;
  --card-bg: #FFFFFF;
  --sidebar-bg: #1D2129;
  --text-primary: #1D2129;
  --text-secondary: #4E5969;
  --text-tertiary: #86909C;
  --border: #E5E6EB;
  --success: #00B42A;
  --warning: #FF7D00;
  --danger: #F53F3F;
  --radius: 12rpx;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg);
}

/* ===== 登录页 ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #FFF5EE 0%, #FFF8F0 100%);
}

.login-card {
  width: 400px;
  max-width: 90%;
  background: white;
  border-radius: 16px;
  padding: 48px 40px;
  box-shadow: 0 8px 40px rgba(255,107,53,0.1);
}

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

.login-logo h1 {
  font-size: 28px;
  color: var(--primary);
  margin-bottom: 8px;
}

.login-logo p {
  font-size: 14px;
  color: var(--text-tertiary);
}

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

.login-form label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.login-form input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 16px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.login-form input:focus {
  border-color: var(--primary);
}

.login-form .btn {
  width: 100%;
  height: 44px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.login-form .btn:hover { opacity: 0.9; }
.login-form .btn:disabled { opacity: 0.6; cursor: not-allowed; }

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
  text-align: center;
}

/* ===== 布局 ===== */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  color: white;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-header h2 {
  font-size: 18px;
  color: var(--primary-light);
}

.sidebar-header p {
  font-size: 12px;
  opacity: 0.5;
  margin-top: 4px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
  border-left: 3px solid transparent;
}

.nav-item:hover { color: white; background: rgba(255,255,255,0.04); }

.nav-item.active {
  color: var(--primary-light);
  background: rgba(255,107,53,0.1);
  border-left-color: var(--primary);
}

.nav-item .icon { margin-right: 10px; font-size: 16px; }
.nav-item .badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
}

.main-area { margin-left: 220px; flex: 1; min-height: 100vh; }

.topbar {
  background: white;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title { font-size: 16px; font-weight: 600; }

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

.topbar-user { font-size: 13px; color: var(--text-secondary); }

.logout-btn {
  background: none;
  border: 1px solid var(--border);
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.logout-btn:hover { border-color: var(--danger); color: var(--danger); }

.content { padding: 24px; }

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

.stat-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat-card .label {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 700;
}

.stat-card .value.primary { color: var(--primary); }
.stat-card .value.success { color: var(--success); }
.stat-card .value.danger { color: var(--danger); }
.stat-card .value.warning { color: var(--warning); }

/* ===== 表格 ===== */
.data-table { background: white; border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }

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

.table-header h3 { font-size: 15px; font-weight: 600; }

.table-toolbar { display: flex; align-items: center; gap: 12px; }

.table-toolbar input {
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 12px;
  font-size: 13px;
  outline: none;
}

.table-toolbar input:focus { border-color: var(--primary); }

.table-toolbar select {
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 8px;
  font-size: 13px;
  outline: none;
}

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

thead th {
  background: #FAFAFA;
  padding: 12px 20px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 12px 20px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

tbody tr:hover { background: #FAFBFC; }
tbody tr:last-child td { border-bottom: none; }

.status-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.status-tag.safe { background: #E8F8E8; color: var(--success); }
.status-tag.warning { background: #FFF3E0; color: var(--warning); }
.status-tag.danger { background: #FFE8E8; color: var(--danger); }
.status-tag.handled { background: #E8F4FF; color: #165DFF; }
.status-tag.triggered { background: #FFE8E8; color: var(--danger); }

/* ===== 分页 ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
}

.pagination button {
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.pagination button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pagination button.active { background: var(--primary); color: white; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination .page-info { font-size: 13px; color: var(--text-tertiary); }

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-tertiary);
}

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

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

.modal {
  background: white;
  border-radius: 16px;
  width: 500px;
  max-width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 32px;
  box-shadow: 0 16px 64px rgba(0,0,0,0.15);
}

.modal h3 { font-size: 18px; margin-bottom: 20px; }

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

.modal label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.modal input, .modal select, .modal textarea {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.modal textarea { height: auto; padding: 10px 12px; resize: vertical; }
.modal input:focus { border-color: var(--primary); }

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.modal-actions button {
  flex: 1;
  height: 40px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity 0.2s;
}

.modal-actions .btn-cancel { background: #F5F6F7; color: var(--text-secondary); }
.modal-actions .btn-confirm { background: var(--primary); color: white; }
.modal-actions .btn-cancel:hover { background: #E5E6EB; }
.modal-actions .btn-confirm:hover { opacity: 0.9; }

/* ===== 加载动画 ===== */
.loading {
  text-align: center;
  padding: 48px;
  color: var(--text-tertiary);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

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

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 16px;
  right: 16px;
  padding: 12px 20px;
  border-radius: 8px;
  color: white;
  font-size: 14px;
  z-index: 999;
  animation: slideIn 0.3s ease;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

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

/* ===== 配置页 ===== */
.config-list {
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.config-item:last-child { border-bottom: none; }

.config-info .key { font-size: 14px; font-weight: 500; margin-bottom: 4px; }
.config-info .desc { font-size: 12px; color: var(--text-tertiary); }
.config-value { font-size: 14px; color: var(--text-secondary); }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .sidebar { width: 64px; }
  .sidebar-header h2, .sidebar-header p, .nav-item span:not(.icon) { display: none; }
  .nav-item { justify-content: center; padding: 12px; }
  .nav-item .icon { margin-right: 0; }
  .main-area { margin-left: 64px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
