/* ==========================================================================
   数据信号分析系统 - 全局样式表
   --------------------------------------------------------------------------
   说明：纯手写 CSS，无任何第三方框架。采用深色侧边栏 + 浅色内容区的
   工业风格配色，兼顾数据看板与后台管理场景。
   ========================================================================== */

/* --------------------------------------------------------------------------
   基础重置与变量
   -------------------------------------------------------------------------- */
:root {
  --primary: #1e6fff;
  --primary-dark: #1558d6;
  --primary-light: #e8f0ff;
  --sidebar-bg: #1c2333;
  --sidebar-hover: #28324a;
  --sidebar-active: #1e6fff;
  --sidebar-text: #aab4c8;
  --topbar-bg: #ffffff;
  --content-bg: #f3f5f9;
  --card-bg: #ffffff;
  --text: #2a3344;
  --text-secondary: #6b7588;
  --border: #e4e8f0;
  --success: #18a058;
  --warning: #f0a020;
  --danger: #d03050;
  --info: #2080f0;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(30, 40, 60, 0.06);
  --shadow-lg: 0 8px 30px rgba(30, 40, 60, 0.14);
  --sidebar-width: 230px;
  --topbar-height: 60px;
}

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

html, body {
  height: 100%;
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--content-bg);
  font-size: 14px;
  line-height: 1.6;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-dark);
}

/* --------------------------------------------------------------------------
   登录 / 注册页
   -------------------------------------------------------------------------- */
.auth-page {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1c2a4d 0%, #1e6fff 55%, #38a1ff 100%);
  position: relative;
  overflow: hidden;
}

.auth-page::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  top: -180px;
  right: -120px;
}

.auth-page::after {
  content: '';
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  bottom: -140px;
  left: -100px;
}

.auth-card {
  position: relative;
  z-index: 2;
  width: 420px;
  max-width: 92vw;
  background: #fff;
  border-radius: 14px;
  padding: 40px 36px 32px;
  box-shadow: var(--shadow-lg);
}

.auth-card .auth-title {
  text-align: center;
  margin-bottom: 6px;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.auth-card .auth-subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 28px;
  font-size: 13px;
}

.auth-card .form-item {
  margin-bottom: 18px;
}

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

.auth-card .form-input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  transition: border-color .2s, box-shadow .2s;
}

.auth-card .form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 111, 255, 0.12);
}

.auth-card .btn-primary {
  width: 100%;
  height: 44px;
  margin-top: 6px;
}

.auth-footer {
  text-align: center;
  margin-top: 18px;
  color: var(--text-secondary);
  font-size: 13px;
}

/* --------------------------------------------------------------------------
   整体布局：侧边栏 + 顶部栏 + 内容区
   -------------------------------------------------------------------------- */
.layout {
  display: flex;
  min-height: 100vh;
}

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

.sidebar .brand {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 20px;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 1px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar .brand .logo {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: linear-gradient(135deg, #1e6fff, #38a1ff);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
  font-size: 15px;
  color: #fff;
}

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

.sidebar .menu::-webkit-scrollbar {
  width: 5px;
}

.sidebar .menu::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.menu-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  cursor: pointer;
  color: var(--sidebar-text);
  transition: background .2s, color .2s;
  font-size: 14px;
  border-left: 3px solid transparent;
}

.menu-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.menu-item.active {
  background: var(--sidebar-hover);
  color: #fff;
  border-left-color: var(--primary);
}

.menu-item .menu-icon {
  width: 22px;
  margin-right: 10px;
  text-align: center;
  font-size: 15px;
}

.sidebar .sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--sidebar-text);
  font-size: 12px;
}

.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: var(--topbar-height);
  background: var(--topbar-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: 0 1px 4px rgba(30, 40, 60, 0.06);
  position: sticky;
  top: 0;
  z-index: 90;
}

.topbar .page-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

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

.bell-btn {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--content-bg);
  border: none;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background .2s;
}

.bell-btn:hover {
  background: var(--primary-light);
}

.bell-btn .badge-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.user-chip .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e6fff, #38a1ff);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}

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

.user-chip .user-role {
  font-size: 12px;
  color: var(--text-secondary);
}

.logout-btn {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  transition: all .2s;
}

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

/* --------------------------------------------------------------------------
   内容区
   -------------------------------------------------------------------------- */
.content {
  flex: 1;
  padding: 20px 24px;
  overflow-x: hidden;
}

/* --------------------------------------------------------------------------
   卡片
   -------------------------------------------------------------------------- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 18px;
}

.card .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.card .card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

/* --------------------------------------------------------------------------
   统计卡片（看板）
   -------------------------------------------------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform .2s, box-shadow .2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stat-card .stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #fff;
  flex-shrink: 0;
}

.stat-card .stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.icon-blue { background: linear-gradient(135deg, #1e6fff, #38a1ff); }
.icon-green { background: linear-gradient(135deg, #18a058, #36c97a); }
.icon-orange { background: linear-gradient(135deg, #f0a020, #ffc53d); }
.icon-red { background: linear-gradient(135deg, #d03050, #ff6b6b); }
.icon-purple { background: linear-gradient(135deg, #7c4dff, #a78bfa); }

/* --------------------------------------------------------------------------
   图表区
   -------------------------------------------------------------------------- */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}

.chart-box {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.chart-box .chart-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}

.chart-box canvas {
  width: 100%;
  height: 260px;
  display: block;
}

/* --------------------------------------------------------------------------
   工具栏（筛选）
   -------------------------------------------------------------------------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.toolbar .form-input,
.toolbar .form-select {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: #fff;
}

.toolbar .form-input {
  width: 180px;
}

.toolbar .form-select {
  min-width: 120px;
}

.toolbar .form-input:focus,
.toolbar .form-select:focus {
  outline: none;
  border-color: var(--primary);
}

.toolbar .spacer {
  flex: 1;
}

/* --------------------------------------------------------------------------
   按钮
   -------------------------------------------------------------------------- */
.btn {
  height: 36px;
  padding: 0 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13px;
  transition: all .2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover {
  background: #138a4b;
}

.btn-warning {
  background: var(--warning);
  color: #fff;
}

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

.btn-danger {
  background: var(--danger);
  color: #fff;
}

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

.btn-plain {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

.btn-plain:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-text {
  background: transparent;
  color: var(--primary);
  padding: 0 6px;
  height: auto;
}

.btn-text:hover {
  color: var(--primary-dark);
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

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

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

table.table thead th {
  background: #f7f9fc;
  color: var(--text-secondary);
  font-weight: 600;
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.table tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

table.table tbody tr:hover {
  background: #fafbfe;
}

table.table .empty-row td {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 0;
}

/* --------------------------------------------------------------------------
   标签 / 徽章
   -------------------------------------------------------------------------- */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.6;
  white-space: nowrap;
}

.badge-success { background: #e6f7ee; color: var(--success); }
.badge-warning { background: #fff6e6; color: var(--warning); }
.badge-danger { background: #fde8ec; color: var(--danger); }
.badge-info { background: #e8f0ff; color: var(--info); }
.badge-gray { background: #eef1f6; color: var(--text-secondary); }
.badge-purple { background: #f0ebff; color: #7c4dff; }

/* --------------------------------------------------------------------------
   分页
   -------------------------------------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.pagination .page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  transition: all .2s;
}

.pagination .page-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.pagination .page-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

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

.pagination .page-info {
  color: var(--text-secondary);
  font-size: 13px;
  margin-right: 4px;
}

/* --------------------------------------------------------------------------
   模态框
   -------------------------------------------------------------------------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 26, 40, 0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  background: #fff;
  border-radius: 12px;
  width: 560px;
  max-width: 94vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn .18s ease;
}

@keyframes modalIn {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal.modal-lg { width: 720px; }

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

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

.modal .modal-close {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: 6px;
}

.modal .modal-close:hover {
  background: var(--content-bg);
}

.modal .modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal .modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* --------------------------------------------------------------------------
   表单
   -------------------------------------------------------------------------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
}

.form-grid .form-item.full {
  grid-column: 1 / -1;
}

.form-item label {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  color: var(--text-secondary);
}

.form-item label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  transition: border-color .2s;
}

.form-textarea {
  height: auto;
  min-height: 80px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.6;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.form-input.error,
.form-select.error,
.form-textarea.error {
  border-color: var(--danger);
}

.form-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* --------------------------------------------------------------------------
   提示消息（Toast）
   -------------------------------------------------------------------------- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  min-width: 240px;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  animation: toastIn .25s ease;
  border-left: 4px solid var(--info);
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

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

/* --------------------------------------------------------------------------
   预警等级颜色
   -------------------------------------------------------------------------- */
.warn-urgent { color: var(--danger); font-weight: 600; }
.warn-important { color: var(--warning); font-weight: 600; }
.warn-normal { color: var(--text-secondary); }

/* --------------------------------------------------------------------------
   响应式
   -------------------------------------------------------------------------- */
@media (max-width: 1200px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .stat-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .sidebar { width: 60px; min-width: 60px; }
  .sidebar .brand span,
  .sidebar .menu-item span,
  .sidebar .sidebar-footer { display: none; }
  .sidebar .brand { justify-content: center; padding: 0; }
  .sidebar .menu-item { justify-content: center; padding: 14px 0; }
  .main { margin-left: 60px; }
}
