/* ============================================================
   Lexcom OpsAlert — 运维告警管理系统
   Design: Light Precision Console
   ============================================================ */

/* --- 本地字体 --- */
@import url('fonts.css');

/* ============================================================
   CSS Custom Properties
   ============================================================ */
:root {
  /* 色彩体系（亮色） */
  --bg-root:       #f1f5f9;
  --bg-surface:    #e2e8f0;
  --bg-card:       #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input:      #ffffff;
  --bg-sidebar:    #ffffff;
  --bg-topnav:     #ffffff;
  --bg-overlay:    rgba(0, 0, 0, 0.35);

  --border-default: #cbd5e1;
  --border-subtle:  #e2e8f0;
  --border-focus:   #3b82f6;

  --accent:        #2563eb;
  --accent-hover:  #3b82f6;
  --accent-muted:  rgba(37, 99, 235, 0.08);
  --accent-glow:   rgba(37, 99, 235, 0.15);

  --success:       #059669;
  --success-bg:    rgba(5, 150, 105, 0.08);
  --warning:       #d97706;
  --warning-bg:    rgba(217, 119, 6, 0.08);
  --danger:        #dc2626;
  --danger-bg:     rgba(220, 38, 38, 0.08);
  --info:          #0891b2;
  --info-bg:       rgba(8, 145, 178, 0.08);

  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --text-inverse:   #f8fafc;

  /* 字体 */
  --font-display: 'Outfit', system-ui, sans-serif;
  --font-body:    'Manrope', system-ui, sans-serif;
  --font-mono:    'IBM Plex Mono', 'Fira Code', monospace;

  /* 圆角 */
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --radius-xl:  16px;

  /* 阴影 */
  --shadow-sm:   0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg:   0 8px 24px rgba(0,0,0,0.1);
  --shadow-glow: 0 0 16px var(--accent-glow);

  /* 布局 */
  --sidebar-width: 260px;
  --sidebar-collapsed: 64px;
  --topnav-height: 56px;

  /* 动画 */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;

  /* 半透明覆盖色 */
  --hover-bg:       rgba(0,0,0,0.03);
  --hover-bg-strong: rgba(0,0,0,0.05);
  --table-header-bg: rgba(0,0,0,0.03);
  --skeleton-mid:    #e2e8f0;
  --grid-line:       rgba(59, 130, 246, 0.04);
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--bg-root);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* 微妙的网格纹理背景 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}

a { color: var(--accent); text-decoration: none; transition: color var(--duration-fast); }
a:hover { color: var(--accent-hover); }

img { max-width: 100%; display: block; }

::selection {
  background: var(--accent);
  color: var(--text-primary);
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   Typography
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.375rem; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 1.125rem; font-weight: 600; }
h4 { font-size: 1rem; font-weight: 600; }

.text-mono { font-family: var(--font-mono); }
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* ============================================================
   Layout: App Shell
   ============================================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* --- 侧边栏 --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: width var(--duration-normal) var(--ease-out),
              transform var(--duration-normal) var(--ease-out);
  overflow: hidden;
}

.sidebar-header {
  height: var(--topnav-height);
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-subtle);
  gap: 12px;
  flex-shrink: 0;
}

.sidebar-logo {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--accent), #818cf8);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.85rem;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.sidebar-subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
}

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

.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.nav-group {
  margin-bottom: 8px;
}

.nav-group-label {
  padding: 8px 12px 4px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  white-space: nowrap;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast);
  white-space: nowrap;
  text-decoration: none;
  position: relative;
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--hover-bg);
}

.nav-item.active {
  color: var(--accent-hover);
  background: var(--accent-muted);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.1rem;
}

/* --- 主内容区 --- */
.main-area {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--duration-normal) var(--ease-out);
}

/* --- 顶部导航 --- */
.topnav {
  height: var(--topnav-height);
  background: var(--bg-topnav);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 90;
  gap: 16px;
  backdrop-filter: blur(12px);
}

.topnav-toggle {
  display: none;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 1.2rem;
  align-items: center;
  justify-content: center;
}

.topnav-toggle:hover { color: var(--text-primary); background: var(--hover-bg-strong); }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
}

.breadcrumb-item { color: var(--text-muted); }
.breadcrumb-item a { color: var(--text-secondary); }
.breadcrumb-item a:hover { color: var(--accent); }
.breadcrumb-sep { color: var(--text-muted); font-size: 0.7rem; }
.breadcrumb-item.current { color: var(--text-primary); font-weight: 500; }

.topnav-spacer { flex: 1; }

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

/* --- 内容区 --- */
.content {
  flex: 1;
  padding: 24px;
  max-width: 1400px;
  width: 100%;
}

.content-wide {
  max-width: 100%;
}

/* --- 页面标题区 --- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header h1 {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-header-icon {
  font-size: 1.5rem;
}

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

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--duration-fast);
}

.card:hover {
  border-color: var(--accent-muted);
}

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

.card-header h3 {
  font-size: 0.95rem;
}

.card-body {
  padding: 20px;
}

.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* KPI 卡片 */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
}

.kpi-card.blue::before    { background: linear-gradient(90deg, var(--accent), transparent); }
.kpi-card.green::before   { background: linear-gradient(90deg, var(--success), transparent); }
.kpi-card.orange::before  { background: linear-gradient(90deg, var(--warning), transparent); }
.kpi-card.red::before     { background: linear-gradient(90deg, var(--danger), transparent); }
.kpi-card.cyan::before    { background: linear-gradient(90deg, var(--info), transparent); }

.kpi-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
}

.kpi-value.blue   { color: var(--accent); }
.kpi-value.green  { color: var(--success); }
.kpi-value.orange { color: var(--warning); }
.kpi-value.red    { color: var(--danger); }
.kpi-value.cyan   { color: var(--info); }

.kpi-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ============================================================
   Tables
   ============================================================ */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  flex-wrap: wrap;
}

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

.data-table thead th {
  background: var(--table-header-bg);
  padding: 10px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--border-subtle);
  cursor: default;
  user-select: none;
}

.data-table thead th.sortable {
  cursor: pointer;
}

.data-table thead th.sortable:hover {
  color: var(--text-secondary);
}

.data-table thead th .sort-icon {
  margin-left: 4px;
  font-size: 0.65rem;
  opacity: 0.4;
}

.data-table thead th.sorted .sort-icon {
  opacity: 1;
  color: var(--accent);
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--duration-fast);
}

.data-table tbody tr:hover {
  background: var(--hover-bg);
}

.data-table tbody td {
  padding: 12px 16px;
  font-size: 0.875rem;
  vertical-align: middle;
}

.data-table tbody td.mono {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.data-table tbody td.truncate {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state-text {
  font-size: 0.9rem;
  margin-bottom: 16px;
}

/* 分页 */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.pagination-info {
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.pagination-btns {
  display: flex;
  gap: 4px;
}

.pagination-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-default);
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  transition: all var(--duration-fast);
}

.pagination-btn:hover:not(:disabled) {
  background: var(--accent-muted);
  border-color: var(--accent);
  color: var(--accent);
}

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

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

/* ============================================================
   Forms
   ============================================================ */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

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

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.875rem;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-input:disabled,
.form-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.form-inline {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* 搜索框 */
.search-box {
  position: relative;
}

.search-box .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}

.search-box .form-input {
  padding-left: 34px;
}

/* Switch 开关 */
.switch {
  position: relative;
  display: inline-flex;
  width: 40px;
  height: 22px;
  cursor: pointer;
}

.switch input { display: none; }

.switch-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: 11px;
  transition: all var(--duration-fast);
}

.switch-slider::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all var(--duration-fast);
}

.switch input:checked + .switch-slider {
  background: var(--accent);
  border-color: var(--accent);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(18px);
  background: #fff;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

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

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

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: var(--shadow-glow);
}

.btn-secondary {
  background: transparent;
  border-color: var(--border-default);
  color: var(--text-secondary);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--text-muted);
  color: var(--text-primary);
  background: var(--hover-bg);
}

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

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

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

.btn-success:hover:not(:disabled) {
  background: #059669;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 10px;
}

.btn-ghost:hover { color: var(--text-primary); background: var(--hover-bg-strong); }

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

.btn-lg {
  padding: 12px 24px;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 1.1rem;
}

/* ============================================================
   Badges / Tags
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.6;
}

.badge-blue   { background: var(--accent-muted); color: var(--accent-hover); }
.badge-green  { background: var(--success-bg); color: var(--success); }
.badge-orange { background: var(--warning-bg); color: var(--warning); }
.badge-red    { background: var(--danger-bg); color: var(--danger); }
.badge-cyan   { background: var(--info-bg); color: var(--info); }
.badge-gray   { background: rgba(100,116,139,0.15); color: var(--text-secondary); }

.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* 级别标签 */
.level-critical { color: var(--danger); }
.level-warning  { color: var(--warning); }
.level-info     { color: var(--info); }

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-normal), visibility var(--duration-normal);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(12px) scale(0.97);
  transition: transform var(--duration-normal) var(--ease-out);
}

.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 20px 24px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.05rem;
}

.modal-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 1.2rem;
}

.modal-close:hover { color: var(--text-primary); background: var(--hover-bg-strong); }

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

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ============================================================
   Toast Notifications
   ============================================================ */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 300px;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toastIn var(--duration-normal) var(--ease-out);
}

.toast.removing {
  animation: toastOut var(--duration-fast) ease-in forwards;
}

.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon   { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon    { color: var(--info); }

.toast-message {
  flex: 1;
  font-size: 0.85rem;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  font-size: 1rem;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(60px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(60px); }
}

/* ============================================================
   Loading
   ============================================================ */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-default);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

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

/* 骨架屏 */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--skeleton-mid) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
   Wizard Steps (应用导入)
   ============================================================ */
.wizard-steps {
  display: flex;
  align-items: center;
  margin-bottom: 32px;
  position: relative;
}

.wizard-step {
  flex: 1;
  text-align: center;
  position: relative;
}

.wizard-step-num {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 2px solid var(--border-default);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  transition: all var(--duration-normal);
}

.wizard-step.active .wizard-step-num {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 12px var(--accent-glow);
}

.wizard-step.done .wizard-step-num {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.wizard-step-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  transition: color var(--duration-fast);
}

.wizard-step.active .wizard-step-label,
.wizard-step.done .wizard-step-label {
  color: var(--text-primary);
}

.wizard-step::after {
  content: '';
  position: absolute;
  top: 18px;
  left: calc(50% + 24px);
  right: calc(-50% + 24px);
  height: 2px;
  background: var(--border-default);
  transition: background var(--duration-normal);
}

.wizard-step:last-child::after { display: none; }

.wizard-step.done::after {
  background: var(--success);
}

/* ============================================================
   Schedule Grid (排班表)
   ============================================================ */
.schedule-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.schedule-day {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: center;
  transition: all var(--duration-fast);
  cursor: pointer;
  min-height: 120px;
}

.schedule-day:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
}

.schedule-day.today {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

.schedule-day-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.schedule-day.today .schedule-day-label {
  color: var(--accent);
}

.schedule-person {
  background: var(--accent-muted);
  border-radius: var(--radius-md);
  padding: 8px;
  margin-top: 8px;
}

.schedule-person-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.schedule-person-id {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ============================================================
   Status Dot (实时脉冲)
   ============================================================ */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  position: relative;
}

.status-dot.pulse::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid currentColor;
  animation: pulse 2s ease-out infinite;
}

.status-dot.open  { background: var(--danger); color: var(--danger); }
.status-dot.closed { background: var(--success); color: var(--success); }

@keyframes pulse {
  0%   { opacity: 0.6; transform: scale(1); }
  100% { opacity: 0; transform: scale(2); }
}

/* ============================================================
   File Upload Zone
   ============================================================ */
.upload-zone {
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--duration-fast);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-muted);
}

.upload-zone-icon {
  font-size: 2.5rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.upload-zone-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.upload-zone-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ============================================================
   Tabs
   ============================================================ */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 20px;
}

.tab-item {
  padding: 10px 20px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: color var(--duration-fast);
  border: none;
  background: none;
  font-family: var(--font-body);
}

.tab-item:hover { color: var(--text-secondary); }

.tab-item.active {
  color: var(--accent);
}

.tab-item.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 1px 1px 0 0;
}

/* ============================================================
   处理方式填写页 (移动端优先)
   ============================================================ */
.mobile-page {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px;
  min-height: 100vh;
}

.mobile-header {
  text-align: center;
  padding: 20px 0;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 24px;
}

.mobile-header h2 {
  font-size: 1.25rem;
}

.mobile-info-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 20px;
}

.mobile-info-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.85rem;
}

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

.mobile-info-label {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.mobile-info-value {
  text-align: right;
  font-weight: 500;
  word-break: break-word;
}

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

.mobile-form .form-label {
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.mobile-form .form-input,
.mobile-form .form-select,
.mobile-form .form-textarea {
  padding: 12px 16px;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

.mobile-form .btn {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

.success-message {
  text-align: center;
  padding: 48px 20px;
}

.success-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
}

.success-text {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

/* ============================================================
   Charts 区域
   ============================================================ */
.chart-container {
  position: relative;
  width: 100%;
  padding: 16px;
}

.chart-container canvas {
  width: 100% !important;
}

/* ============================================================
   Utility Classes
   ============================================================ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.p-16 { padding: 16px; }
.p-20 { padding: 20px; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ============================================================
   Theme / Language Toggle
   ============================================================ */
.topnav-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-default);
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all var(--duration-fast);
}

.topnav-btn:hover {
  color: var(--text-primary);
  background: var(--hover-bg-strong);
  border-color: var(--text-muted);
}

.lang-btn {
  width: auto;
  padding: 0 8px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ============================================================
   入场动画
   ============================================================ */
.fade-in {
  animation: fadeIn var(--duration-normal) var(--ease-out);
}

.slide-up {
  animation: slideUp var(--duration-slow) var(--ease-out);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

/* 交错动画 */
.stagger > * {
  animation: slideUp var(--duration-slow) var(--ease-out) backwards;
}
.stagger > *:nth-child(1) { animation-delay: 50ms; }
.stagger > *:nth-child(2) { animation-delay: 100ms; }
.stagger > *:nth-child(3) { animation-delay: 150ms; }
.stagger > *:nth-child(4) { animation-delay: 200ms; }
.stagger > *:nth-child(5) { animation-delay: 250ms; }
.stagger > *:nth-child(6) { animation-delay: 300ms; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-area {
    margin-left: 0;
  }

  .topnav-toggle {
    display: flex;
  }

  .content { padding: 16px; }

  .schedule-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .schedule-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
}
