/* 沈师傅线下业务端 - 共享样式 */
:root {
  --primary: #8B2A2A;
  --primary-light: #A33F3F;
  --primary-dark: #6B1F1F;
  --secondary: #2D5F3F;
  --secondary-light: #3D7A52;
  --bg: #F5F6FA;
  --card-bg: #FFFFFF;
  --text: #1F2937;
  --text-secondary: #6B7280;
  --border: #E5E7EB;
  --shadow: 0 4px 20px rgba(0,0,0,0.06);
  --radius: 12px;
  --sidebar-dark: #1A1A2E;
  --sidebar-dark-hover: #252542;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #3B82F6;
}

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

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
}

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

.login-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 420px;
  padding: 48px 40px;
  text-align: center;
}

.login-logo {
  width: 110px;
  height: 110px;
  object-fit: contain;
  margin-bottom: 16px;
}

.login-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 6px;
  letter-spacing: 1px;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 32px;
}

.form-group {
  margin-bottom: 20px;
  text-align: left;
}

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

.form-control {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  transition: all .2s;
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139,42,42,0.08);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all .2s;
}

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

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

.btn-secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: #F9FAFB; }

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

.btn-sm { padding: 7px 12px; font-size: 12px; }
.btn-lg { padding: 14px 24px; font-size: 15px; width: 100%; }

.hint-text {
  margin-top: 20px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.6;
}

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

/* 深色侧边栏 - 管理员 */
.sidebar-dark {
  width: 240px;
  background: var(--sidebar-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 3px;
}

.sidebar-brand-text {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

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

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  color: rgba(255,255,255,0.72);
  cursor: pointer;
  transition: all .15s;
  border-left: 3px solid transparent;
}

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

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

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

/* 浅色侧边栏 - 员工 */
.sidebar-light {
  width: 220px;
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-light .sidebar-brand {
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.sidebar-light .sidebar-brand img {
  background: transparent;
  padding: 0;
}

.sidebar-light .menu-item {
  color: var(--text-secondary);
  border-left: 3px solid transparent;
}

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

.sidebar-light .menu-item.active {
  background: rgba(139,42,42,0.06);
  color: var(--primary);
  border-left-color: var(--primary);
}

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

.main-content.user-layout { margin-left: 220px; }

.topbar {
  height: 64px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 90;
}

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

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}

.user-name {
  font-weight: 500;
  font-size: 14px;
}

.user-role {
  font-size: 12px;
  color: var(--text-secondary);
  background: #F3F4F6;
  padding: 2px 8px;
  border-radius: 20px;
}

.content-body {
  flex: 1;
  padding: 24px 28px;
}

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

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.page-desc {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 4px;
}

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

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

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

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.stat-trend {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.trend-up { color: var(--danger); }
.trend-down { color: var(--success); }

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

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

.card-title {
  font-size: 15px;
  font-weight: 600;
}

.card-body {
  padding: 22px;
}

/* 图表容器 */
.chart-container {
  width: 100%;
  height: 320px;
}

.charts-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 20px;
}

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

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

.data-table th,
.data-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table th {
  background: #F9FAFB;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.data-table tr:hover td { background: #FAFBFC; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.badge-success { background: #D1FAE5; color: #065F46; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-danger { background: #FEE2E2; color: #991B1B; }
.badge-info { background: #DBEAFE; color: #1E40AF; }
.badge-default { background: #F3F4F6; color: #4B5563; }

/* 进度条 */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: #E5E7EB;
  border-radius: 4px;
  overflow: hidden;
  min-width: 80px;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .5s ease;
}

.progress-fill.high { background: var(--success); }
.progress-fill.mid { background: var(--warning); }
.progress-fill.low { background: var(--danger); }

/* 筛选栏 */
.filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 18px;
}

.filter-bar .form-control { width: auto; min-width: 140px; }

/* 模态框 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-overlay.active { display: flex; }

.modal {
  background: #fff;
  border-radius: var(--radius);
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
}

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

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

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

.close-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-secondary);
}

/* 导入区域 */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .2s;
}

.upload-area:hover {
  border-color: var(--primary);
  background: rgba(139,42,42,0.02);
}

/* 标签页 */
.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  padding: 10px 18px;
  cursor: pointer;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  font-weight: 500;
  font-size: 13px;
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* 汉堡菜单按钮 - 仅移动端显示 */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  transition: background .2s;
  -webkit-tap-highlight-color: transparent;
}

.menu-toggle:active { background: #F3F4F6; }

/* 侧边栏遮罩层 - 仅移动端 */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
  opacity: 0;
  transition: opacity .3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ============ 移动端响应式 ============ */

/* 平板及以下 */
@media (max-width: 1024px) {
  .charts-row {
    grid-template-columns: 1fr;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .chart-container {
    height: 280px;
  }
}

/* 手机端 */
@media (max-width: 768px) {
  /* 汉堡按钮显示 */
  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* 侧边栏变抽屉 */
  .sidebar-dark, .sidebar-light {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    transform: translateX(-100%);
    transition: transform .3s ease;
    z-index: 200;
  }

  .sidebar-dark.open, .sidebar-light.open {
    transform: translateX(0);
  }

  /* 主内容区全宽 */
  .main-content, .main-content.user-layout {
    margin-left: 0;
  }

  /* 顶栏调整 */
  .topbar {
    height: 56px;
    padding: 0 12px 0 8px;
  }

  .topbar-title {
    font-size: 16px;
    flex: 1;
    text-align: center;
  }

  .topbar-user {
    gap: 6px;
  }

  .user-name {
    display: none;
  }

  .user-role {
    font-size: 10px;
    padding: 2px 6px;
  }

  .user-avatar {
    width: 30px;
    height: 30px;
    font-size: 12px;
  }

  .topbar .btn-sm {
    padding: 5px 8px;
    font-size: 11px;
  }

  /* 内容区内边距缩小 */
  .content-body {
    padding: 14px 12px;
  }

  /* 页面标题区 */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
  }

  .page-title {
    font-size: 18px;
  }

  .page-desc {
    font-size: 12px;
  }

  /* 统计卡片变单列 */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
  }

  .stat-card {
    padding: 14px 12px;
  }

  .stat-value {
    font-size: 20px;
  }

  .stat-label {
    font-size: 11px;
  }

  /* 图表区单列 */
  .charts-row {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .chart-container {
    height: 240px;
  }

  /* 卡片内边距缩小 */
  .card-body {
    padding: 14px;
  }

  .card-header {
    padding: 12px 14px;
  }

  .card-title {
    font-size: 14px;
  }

  /* 表格保持横向滚动，字号缩小 */
  .data-table {
    font-size: 12px;
  }

  .data-table th, .data-table td {
    padding: 8px 10px;
  }

  /* 筛选栏纵向排列 */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-bar .form-control {
    width: 100%;
    min-width: 0;
  }

  /* 模态框接近全屏 */
  .modal {
    width: 95%;
    max-width: none;
    max-height: 92vh;
    border-radius: 10px;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-header {
    padding: 14px 16px;
  }

  .modal-footer {
    padding: 12px 16px;
  }

  /* 按钮组在小屏下占满宽度 */
  .page-header .btn,
  .card-header .btn {
    width: 100%;
  }

  .card-header {
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
  }

  /* 登录页调整 */
  .login-card {
    padding: 32px 24px;
  }

  .login-logo {
    width: 80px;
    height: 80px;
  }

  .login-title {
    font-size: 20px;
  }

  /* Toast 调整 */
  .toast {
    top: 10px;
    right: 10px;
    left: 10px;
    text-align: center;
    font-size: 13px;
    padding: 10px 16px;
  }

  /* 上传区域缩小 */
  .upload-area {
    padding: 24px 16px;
  }

  /* 进度条 */
  .progress-bar {
    min-width: 50px;
  }
}

/* 超小屏 (iPhone SE 等) */
@media (max-width: 375px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stat-value {
    font-size: 18px;
  }

  .topbar-title {
    font-size: 15px;
  }

  .login-title {
    font-size: 18px;
  }
}

/* Toast */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 14px 20px;
  border-radius: 8px;
  color: #fff;
  font-weight: 500;
  z-index: 300;
  transform: translateX(120%);
  transition: transform .3s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.toast.show { transform: translateX(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--info); }

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

.empty-state-icon {
  font-size: 42px;
  margin-bottom: 12px;
  opacity: .5;
}
