/* ===== CSS变量 ===== */
:root {
  --primary: #1a56db;
  --primary-light: #3b82f6;
  --primary-dark: #1e40af;
  --primary-bg: #eff6ff;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --info: #0891b2;
  --info-bg: #ecfeff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --sidebar-width: 240px;
  --sidebar-collapsed: 64px;
  --topbar-height: 56px;
  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
  --transition: all 0.2s ease;
}

/* ===== 重置 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px; color: var(--gray-800); background: var(--gray-100);
}

/* ===== 登录页 ===== */
.login-overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #064e3b 0%, #065f46 40%, #047857 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  z-index: 9999;
}
.login-overlay::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,0.08) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(16,185,129,0.15) 0%, transparent 40%);
  pointer-events: none;
}
.login-box {
  position: relative; width: 420px; max-width: 92vw; background: rgba(255,255,255,0.97);
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.1);
  overflow: hidden;
}
.login-header {
  background: linear-gradient(135deg, #065f46, #059669); color: #fff;
  padding: 28px 24px 22px; text-align: center;
}
.login-header svg { color: #a7f3d0; margin-bottom: 10px; }
.login-header h1 { font-size: 20px; font-weight: 700; margin: 0 0 4px; letter-spacing: 1px; }
.login-header p { font-size: 13px; opacity: 0.9; margin: 0; }
.login-form { padding: 24px 22px 28px; }
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.form-input {
  width: 100%; padding: 10px 14px; border: 1.5px solid #e5e7eb; border-radius: 10px;
  background: #f9fafb; font-size: 14px; color: #111827; outline: none; transition: var(--transition);
}
.form-input:focus { border-color: #10b981; background: #fff; box-shadow: 0 0 0 3px rgba(16,185,129,0.15); }
.login-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; display: none; }
.login-btn {
  width: 100%; padding: 12px; background: linear-gradient(135deg, #059669, #10b981); color: #fff; border: none; border-radius: 10px;
  font-size: 16px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 4px 6px -1px rgba(16,185,129,0.3); transition: var(--transition); margin-top: 4px;
}
.login-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 12px -2px rgba(16,185,129,0.4); }
.login-btn:active { transform: translateY(0); }
.login-tip { text-align: center; font-size: 12px; color: #6b7280; margin-top: 12px; }
.login-hint { margin-top: 14px; text-align: center; }
.login-hint a { color: #065f46; text-decoration: none; font-weight: 600; font-size: 13px; }
.login-hint a:hover { text-decoration: underline; }

/* ===== 布局 ===== */
#app { display: flex; height: 100vh; }
.sidebar {
  width: var(--sidebar-width); background: #0f172a; color: #e2e8f0;
  display: flex; flex-direction: column; transition: var(--transition); flex-shrink: 0;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar-header {
  height: var(--topbar-height); display: flex; align-items: center; padding: 0 16px; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-header .logo { width: 28px; height: 28px; border-radius: 8px; background: rgba(255,255,255,0.1); display: flex; align-items: center; justify-content: center; color: #a7f3d0; }
.sidebar-header .brand { font-weight: 700; font-size: 14px; color: #f1f5f9; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
.nav-group-title { font-size: 11px; color: #94a3b8; padding: 10px 10px 4px; font-weight: 600; letter-spacing: 0.3px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius);
  color: #cbd5e1; text-decoration: none; margin-bottom: 2px; transition: var(--transition);
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: rgba(96,165,250,0.15); color: #60a5fa; }
.nav-item.active::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; background: #60a5fa; border-radius: 0 4px 4px 0;
}
.nav-item svg { flex-shrink: 0; width: 18px; height: 18px; }
.nav-text { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar-height); background: #fff; border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-size: 16px; font-weight: 700; color: #111827; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.page-container { display: flex; flex-direction: column; flex: 1; overflow-y: auto; padding: 20px; min-height: 0; }

/* ===== 模块通用 ===== */
.module-container { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.module-header { padding: 14px 16px; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; }
.module-header h2 { font-size: 16px; font-weight: 700; color: #111827; }
.module-body { padding: 16px; }
.module-footer { padding: 10px 16px; border-top: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: flex-end; gap: 8px; }

/* ===== 按钮与表单 ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: var(--radius); border: 1px solid transparent;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: var(--transition); background: #fff; color: #374151; border-color: var(--gray-300);
}
.btn:hover { background: var(--gray-50); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: var(--radius-sm); }

input[type="text"], input[type="search"], input[type="password"], input[type="number"], textarea, select {
  padding: 8px 10px; border: 1px solid var(--gray-300); border-radius: var(--radius); background: #fff; font-size: 13px; color: #111827; outline: none; transition: var(--transition);
}
input:focus, textarea:focus, select:focus { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
textarea { resize: vertical; }

/* ===== 表格 ===== */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 10px 12px; border-bottom: 1px solid var(--gray-200); text-align: left; vertical-align: middle; }
.data-table th { background: var(--gray-50); color: #4b5563; font-weight: 600; }
.data-table tr:hover td { background: #f8fafc; }
.status { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.status-已完成, .status-已审核 { background: var(--success-bg); color: #166534; }
.status-进行中, .status-已上报 { background: var(--warning-bg); color: #92400e; }
.status-草稿, .status-计划中 { background: var(--gray-100); color: #374151; }
.status-逾期, .status-异常 { background: var(--danger-bg); color: #991b1b; }

/* ===== 卡片与网格 ===== */
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1024px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.card { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow); }
.card-title { font-size: 14px; font-weight: 700; color: #111827; margin-bottom: 8px; }
.card-meta { font-size: 12px; color: #6b7280; }
.card-actions { margin-top: 10px; display: flex; gap: 8px; }

.empty-state { padding: 24px; text-align: center; color: #6b7280; }

/* ===== 标签页 ===== */
.tabs { display: flex; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--gray-200); background: #fff; }
.tab { padding: 8px 12px; border-radius: var(--radius); border: 1px solid transparent; background: transparent; color: #374151; cursor: pointer; font-size: 13px; }
.tab:hover { background: var(--gray-50); }
.tab.active { background: var(--primary-bg); color: var(--primary); border-color: rgba(59,130,246,0.25); font-weight: 700; }

/* ===== 分页与工具栏 ===== */
.toolbar { display: flex; align-items: center; gap: 10px; padding: 10px 12px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.pagination { display: flex; align-items: center; gap: 6px; padding: 8px 12px; justify-content: flex-end; }
.page-btn { padding: 6px 10px; border-radius: var(--radius-sm); border: 1px solid var(--gray-300); background: #fff; cursor: pointer; font-size: 12px; }
.page-btn:hover { background: var(--gray-50); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== 提示与弹窗 ===== */
.toast {
  position: fixed; right: 16px; bottom: 16px; z-index: 10000; background: #111827; color: #fff;
  padding: 10px 14px; border-radius: var(--radius); box-shadow: var(--shadow-lg); font-size: 13px;
}
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,0.35); display: flex; align-items: center; justify-content: center; z-index: 9998; }
.modal { background: #fff; border-radius: var(--radius-lg); width: 520px; max-width: 92vw; max-height: 85vh; overflow: auto; box-shadow: var(--shadow-lg); }
.modal-header { padding: 14px 16px; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 16px; }
.modal-footer { padding: 10px 16px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 8px; }

/* ===== 颜色辅助 ===== */
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-muted { color: #6b7280; }
.bg-white { background: #fff; }

/* ===== EMBED 系统统一样式（2026-09-27）===== */
/* 隐藏各系统内部导航，只保留工作台统一侧边栏 */
.embed-wrapper iframe {
  width: 100%;
  height: calc(100vh - 140px);
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

/* 针对不同系统的导航隐藏规则 */
.embed-wrapper iframe body::-webkit-scrollbar,
.embed-wrapper iframe body {
  overflow-x: hidden !important;
}

/* ===== 移动端适配修复 ===== */
@media (max-width: 768px) {
  html, body { 
    height: auto; 
    overflow-y: auto; 
    overflow-x: hidden;
  }
  
  #app { 
    display: block; 
    height: auto; 
    min-height: 100vh;
  }
  
  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    z-index: 1000;
    transition: left 0.3s ease;
  }
  
  .sidebar.open {
    left: 0;
  }
  
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
  }
  
  .sidebar.open + .sidebar-overlay {
    display: block;
  }
  
  .main-content {
    width: 100% !important;
    min-height: calc(100vh - 56px);
    overflow-y: auto;
  }
  
  .topbar {
    position: sticky;
    top: 0;
    z-index: 100;
  }
  
  .page-container {
    padding: 12px !important;
    min-height: calc(100vh - 80px);
    overflow-y: visible;
  }
  
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr !important;
  }
  
  .card {
    padding: 12px !important;
    margin-bottom: 10px;
  }
  
  .stat-card {
    padding: 12px !important;
  }
  
  .stat-value {
    font-size: 20px !important;
  }
  
  .nav-text {
    font-size: 14px !important;
  }
  
  .sidebar-header {
    padding: 12px !important;
  }
  
  .nav-item {
    padding: 10px 12px !important;
  }
  
  /* 移动端汉堡菜单按钮 */
  .mobile-menu-btn {
    display: flex !important;
  }
  
  /* 隐藏不需要移动端显示的元素 */
  .desktop-only {
    display: none !important;
  }
}

/* 汉堡菜单按钮 */
.mobile-menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}

@media (max-width: 768px) {
  .mobile-menu-btn {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
  }
  
  .mobile-menu-btn span {
    display: block;
    width: 24px;
    height: 2px;
    background: #333;
    border-radius: 1px;
  }
}
