/* ===== 全局重置 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-font-smoothing: antialiased; }
body { background: #f0f2f5; font-family: -apple-system, 'PingFang SC', 'Helvetica Neue', 'Microsoft YaHei', sans-serif; display: flex; min-height: 100vh; font-size: 14px; color: #333; }

/* ===== 侧边栏 ===== */
.sidebar {
  width: 220px; min-height: 100vh; background: #001529; position: fixed;
  left: 0; top: 0; bottom: 0; overflow-y: auto; z-index: 100;
  display: flex; flex-direction: column;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }
.sidebar-logo {
  height: 64px; display: flex; align-items: center; padding: 0 20px; gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.logo-icon {
  width: 36px; height: 36px; background: #07c160; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.logo-text { color: #fff; font-size: 15px; font-weight: 600; line-height: 1.3; }
.logo-text span { display: block; font-size: 10px; color: rgba(255,255,255,.4); font-weight: 400; }

.nav-group { padding: 8px 0; }
.nav-group-title {
  color: rgba(255,255,255,.35); font-size: 11px; letter-spacing: 1px;
  padding: 12px 20px 6px; text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 20px; cursor: pointer; color: rgba(255,255,255,.65); font-size: 13.5px;
  transition: all .15s; border-left: 3px solid transparent; user-select: none;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: rgba(255,255,255,.9); }
.nav-item.active { background: rgba(7,193,96,.1); color: #07c160; border-left-color: #07c160; }
.nav-item .nav-icon { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
.nav-item .badge {
  margin-left: auto; background: #ff4d4f; color: #fff; font-size: 11px;
  padding: 1px 6px; border-radius: 10px; min-width: 18px; text-align: center;
}

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

/* 顶栏 */
.topbar {
  height: 64px; background: #fff; border-bottom: 1px solid #e8e8e8;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: sticky; top: 0; z-index: 50;
}
.breadcrumb { display: flex; align-items: center; gap: 6px; color: #999; font-size: 13px; }
.breadcrumb span:last-child { color: #333; font-weight: 500; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-avatar {
  width: 32px; height: 32px; background: #07c160; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 14px; font-weight: 600;
}
.topbar-user { font-size: 13px; color: #333; }

/* 页面内容 */
.page-content { flex: 1; padding: 24px; }
.page { display: none; }
.page.active { display: block; }

/* ===== 通用组件 ===== */
.page-title { font-size: 20px; font-weight: 600; color: #1a1a1a; margin-bottom: 4px; }
.page-desc { color: #999; font-size: 13px; margin-bottom: 20px; }

.card {
  background: #fff; border-radius: 8px; padding: 20px; margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.card-title { font-size: 15px; font-weight: 600; color: #1a1a1a; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.search-box {
  display: flex; align-items: center; gap: 8px; background: #f5f5f5;
  border-radius: 6px; padding: 7px 12px; border: 1px solid #e8e8e8; min-width: 240px;
}
.search-box input { border: none; background: transparent; outline: none; font-size: 13px; flex: 1; }
.search-box .s-icon { color: #bbb; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: 6px; font-size: 13px; cursor: pointer;
  border: 1px solid #d9d9d9; background: #fff; color: #333; transition: all .15s;
  white-space: nowrap;
}
.btn:hover { border-color: #07c160; color: #07c160; }
.btn-primary { background: #07c160; color: #fff; border-color: #07c160; }
.btn-primary:hover { background: #06ad56; color: #fff; }
.btn-danger { background: #ff4d4f; color: #fff; border-color: #ff4d4f; }
.btn-danger:hover { background: #e6393b; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-link { border: none; background: transparent; color: #07c160; padding: 0; }
.btn-link:hover { color: #06ad56; }
.btn-link.danger { color: #ff4d4f; }
.btn-link.danger:hover { color: #e6393b; }

select {
  padding: 7px 12px; border: 1px solid #d9d9d9; border-radius: 6px;
  font-size: 13px; color: #333; background: #fff; cursor: pointer; outline: none;
}
select:focus { border-color: #07c160; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: #fafafa; padding: 12px 16px; text-align: left;
  font-weight: 500; color: #666; border-bottom: 1px solid #f0f0f0;
  white-space: nowrap;
}
tbody td {
  padding: 12px 16px; border-bottom: 1px solid #f5f5f5;
  color: #333; vertical-align: middle;
}
tbody tr:hover { background: #fafafa; }

/* 标签 */
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.tag-green { background: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f; }
.tag-blue { background: #e6f7ff; color: #1890ff; border: 1px solid #91d5ff; }
.tag-orange { background: #fff7e6; color: #fa8c16; border: 1px solid #ffd591; }
.tag-red { background: #fff2f0; color: #ff4d4f; border: 1px solid #ffccc7; }
.tag-gray { background: #f5f5f5; color: #999; border: 1px solid #d9d9d9; }
.tag-purple { background: #f9f0ff; color: #722ed1; border: 1px solid #d3adf7; }
.tag-cyan { background: #e6fffb; color: #13c2c2; border: 1px solid #87e8de; }
.tag-yellow { background: #fffbe6; color: #d48806; border: 1px solid #ffe58f; }

/* 分页 */
.pagination { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; font-size: 13px; color: #999; }
.pagination .pages { display: flex; gap: 4px; }
.pagination .page-btn {
  min-width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border: 1px solid #d9d9d9; border-radius: 4px; cursor: pointer; font-size: 13px;
  background: #fff; color: #333; padding: 0 8px;
}
.pagination .page-btn:hover { border-color: #07c160; color: #07c160; }
.pagination .page-btn.active { background: #07c160; color: #fff; border-color: #07c160; }

/* 统计卡片 */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card {
  background: #fff; border-radius: 8px; padding: 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06); display: flex; align-items: flex-start; gap: 16px;
}
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0;
}
.stat-icon.green { background: #f6ffed; }
.stat-icon.blue { background: #e6f7ff; }
.stat-icon.orange { background: #fff7e6; }
.stat-icon.red { background: #fff2f0; }
.stat-icon.purple { background: #f9f0ff; }
.stat-info { flex: 1; }
.stat-label { font-size: 13px; color: #999; margin-bottom: 4px; }
.stat-value { font-size: 24px; font-weight: 600; color: #1a1a1a; }
.stat-change { font-size: 12px; margin-top: 4px; }
.stat-change.up { color: #52c41a; }
.stat-change.down { color: #ff4d4f; }

/* 图表占位 */
.chart-row { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }
.chart-placeholder {
  background: #fafafa; border: 1px dashed #e0e0e0; border-radius: 6px;
  height: 200px; display: flex; align-items: center; justify-content: center;
  color: #bbb; font-size: 13px;
}

/* API标签 */
.api-tag {
  display: inline-block; background: #f0f5ff; color: #2f54eb; font-size: 11px;
  padding: 1px 6px; border-radius: 3px; font-family: 'SF Mono', Monaco, monospace; margin-left: 6px;
}

/* 对话框 */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.45);
  display: none; align-items: center; justify-content: center; z-index: 200;
}
.modal-overlay.show { display: flex; }
.modal {
  background: #fff; border-radius: 12px; width: 600px; max-width: 90vw;
  max-height: 85vh; overflow-y: auto; box-shadow: 0 12px 48px rgba(0,0,0,.2);
}
.modal-lg { width: 800px; }
.modal-sm { width: 420px; }
.modal-header {
  padding: 20px 24px 16px; border-bottom: 1px solid #f0f0f0;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close { cursor: pointer; font-size: 20px; color: #999; padding: 4px; }
.modal-close:hover { color: #333; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid #f0f0f0; display: flex; justify-content: flex-end; gap: 10px; }

/* 表单 */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; color: #666; margin-bottom: 6px; font-weight: 500; }
.form-label .required { color: #ff4d4f; margin-left: 2px; }
.form-input {
  width: 100%; padding: 8px 12px; border: 1px solid #d9d9d9; border-radius: 6px;
  font-size: 13px; outline: none; transition: border-color .15s;
}
.form-input:focus { border-color: #07c160; box-shadow: 0 0 0 2px rgba(7,193,96,.1); }
textarea.form-input { min-height: 80px; resize: vertical; }

/* 时间线 */
.timeline { padding: 0 0 0 20px; border-left: 2px solid #e8e8e8; }
.timeline-item { position: relative; padding: 0 0 20px 20px; }
.timeline-item::before {
  content: ''; position: absolute; left: -26px; top: 4px;
  width: 10px; height: 10px; border-radius: 50%; background: #d9d9d9; border: 2px solid #fff;
}
.timeline-item.done::before { background: #07c160; }
.timeline-item.active::before { background: #1890ff; box-shadow: 0 0 0 3px rgba(24,144,255,.2); }
.timeline-time { font-size: 12px; color: #999; margin-bottom: 2px; }
.timeline-content { font-size: 13px; color: #333; }
.timeline-desc { font-size: 12px; color: #999; margin-top: 2px; }

/* 库存进度 */
.stock-bar { display: flex; align-items: center; gap: 8px; }
.stock-track { flex: 1; height: 6px; background: #f0f0f0; border-radius: 3px; overflow: hidden; }
.stock-fill { height: 100%; border-radius: 3px; transition: width .3s; }
.stock-fill.green { background: #52c41a; }
.stock-fill.orange { background: #fa8c16; }
.stock-fill.red { background: #ff4d4f; }
.stock-text { font-size: 12px; color: #999; white-space: nowrap; min-width: 60px; }

/* Tabs */
.tabs { display: flex; border-bottom: 1px solid #e8e8e8; margin-bottom: 16px; }
.tab {
  padding: 10px 20px; cursor: pointer; font-size: 13.5px; color: #666;
  border-bottom: 2px solid transparent; transition: all .15s;
}
.tab:hover { color: #07c160; }
.tab.active { color: #07c160; border-bottom-color: #07c160; font-weight: 500; }

/* 开关 */
.switch {
  width: 36px; height: 20px; background: #d9d9d9; border-radius: 10px;
  position: relative; cursor: pointer; transition: background .2s; display: inline-block;
}
.switch.on { background: #07c160; }
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; background: #fff; border-radius: 50%;
  transition: left .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch.on::after { left: 18px; }

/* 空状态 */
.empty { text-align: center; padding: 60px 20px; color: #bbb; }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-text { font-size: 14px; }

/* 日志 */
.log-row { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px solid #f5f5f5; font-size: 13px; }
.log-time { color: #999; font-size: 12px; white-space: nowrap; min-width: 130px; font-family: 'SF Mono', Monaco, monospace; }
.log-operator { color: #333; font-weight: 500; white-space: nowrap; min-width: 80px; }
.log-action { color: #666; flex: 1; }
.log-ip { color: #bbb; font-size: 12px; white-space: nowrap; }

/* 配置项 */
.config-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0; border-bottom: 1px solid #f5f5f5;
}
.config-label .title { font-size: 13.5px; color: #333; }
.config-label .desc { font-size: 12px; color: #999; margin-top: 2px; }
.config-value { display: flex; align-items: center; gap: 10px; }
.config-input {
  width: 120px; padding: 6px 10px; border: 1px solid #d9d9d9; border-radius: 4px;
  font-size: 13px; text-align: center; outline: none;
}
.config-input:focus { border-color: #07c160; }

/* ===== 登录页 ===== */
.login-wrapper {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #001529 0%, #003a70 100%);
  padding: 20px;
}
.login-card {
  background: #fff; border-radius: 12px; padding: 48px 40px; 
  width: 100%;
  max-width: 420px;
  min-width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
@media (min-width: 768px) {
  .login-card {
    max-width: 480px;
    padding: 56px 48px;
  }
  .login-logo-icon {
    width: 64px;
    height: 64px;
    font-size: 32px;
  }
  .login-logo h2 {
    font-size: 26px;
  }
}
@media (min-width: 1200px) {
  .login-card {
    max-width: 520px;
  }
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo-icon {
  width: 56px; height: 56px; background: #07c160; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; font-size: 28px;
  margin: 0 auto 16px;
}
.login-logo h2 { font-size: 22px; color: #1a1a1a; font-weight: 600; margin-bottom: 6px; }
.login-logo p { font-size: 13px; color: #999; }
.login-form .form-group { margin-bottom: 16px; }
.login-error { color: #ff4d4f; font-size: 13px; margin-bottom: 12px; display: none; padding: 8px 12px; background: #fff2f0; border-radius: 4px; }
.login-btn {
  width: 100%; padding: 11px; background: #07c160; color: #fff; border: none;
  border-radius: 6px; font-size: 15px; font-weight: 500; cursor: pointer; transition: background .15s; margin-top: 8px;
}
.login-btn:hover { background: #06ad56; }
.login-btn:disabled { background: #999; cursor: not-allowed; }
.login-footer { text-align: center; margin-top: 24px; font-size: 12px; color: #bbb; }

/* ===== Toast 通知 ===== */
.toast-container { position: fixed; top: 24px; right: 24px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 20px; border-radius: 6px; color: #fff; font-size: 13px;
  box-shadow: 0 4px 12px rgba(0,0,0,.15); animation: toastIn .3s ease;
  max-width: 360px;
}
.toast-success { background: #52c41a; }
.toast-error { background: #ff4d4f; }
.toast-info { background: #1890ff; }
.toast-hide { animation: toastOut .3s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(100%); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(100%); } }

/* ===== Loading ===== */
.loading-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,.8); display: flex; align-items: center; justify-content: center;
  z-index: 10; border-radius: 8px;
}
.loading-overlay-fixed {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,.7); display: flex; align-items: center; justify-content: center;
  z-index: 300; flex-direction: column; gap: 12px;
}
.loading-overlay-fixed .spinner { width: 32px; height: 32px; }
.spinner {
  width: 24px; height: 24px; border: 3px solid #e8e8e8; border-top-color: #07c160;
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 确认对话框 ===== */
.confirm-content { font-size: 14px; color: #333; padding: 8px 0; }
.confirm-content .highlight { color: #ff4d4f; font-weight: 500; }

/* ===== 详情视图 ===== */
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.detail-item { }
.detail-label { font-size: 12px; color: #999; margin-bottom: 4px; }
.detail-value { font-size: 14px; color: #333; font-weight: 500; }
.detail-value.amount { color: #fa8c16; font-size: 18px; }

/* ===== 辅助类 ===== */
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.p-16 { padding: 16px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-bold { font-weight: 600; }
.text-success { color: #52c41a; }
.text-danger { color: #ff4d4f; }
.text-warning { color: #fa8c16; }
.text-muted { color: #999; }
.text-primary { color: #1890ff; }

/* ===== 图表画布 ===== */
.chart-canvas { width: 100%; height: 200px; }

/* ===== 移动端侧边栏切换按钮 ===== */
.sidebar-toggle {
  display: none;
  position: fixed;
  left: 12px;
  top: 12px;
  width: 40px;
  height: 40px;
  background: #07c160;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.sidebar-mask {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,.5);
  z-index: 150;
}

.sidebar.show { transform: translateX(0); }
.sidebar-mask.show { display: block; }

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

@media (max-width: 768px) {
  /* 侧边栏 */
  .sidebar { 
    transform: translateX(-220px); 
    transition: transform .3s ease;
  }
  .sidebar-toggle { display: flex; align-items: center; justify-content: center; }
  .main { margin-left: 0; }
  
  /* 统计卡片 */
  .stat-grid { grid-template-columns: 1fr; }
  
  /* 表格容器 */
  .table-wrap { 
    overflow-x: auto; 
    -webkit-overflow-scrolling: touch;
  }
  
  /* 页面内容 */
  .page-content { padding: 12px; }
  
  /* 顶栏 */
  .topbar { padding: 0 12px; }
  .topbar-right { gap: 8px; }
  .topbar-user { display: none; }
  
  /* 登录卡片 */
  .login-card { 
    width: 90%; 
    max-width: 360px; 
    padding: 32px 24px; 
  }
  
  /* 按钮 */
  .btn { padding: 6px 12px; font-size: 12px; }
  
  /* 表单 */
  .form-input { padding: 7px 10px; font-size: 12px; }
  
  /* 对话框 */
  .modal { width: 95vw; margin: 10px; }
  .modal-lg { width: 95vw; }
  
  /* 详情网格 */
  .detail-grid { grid-template-columns: 1fr; }
  
  /* 面包屑 */
  .breadcrumb { font-size: 12px; }
  
  /* Toolbar */
  .toolbar { flex-direction: column; align-items: stretch; }
  .search-box { min-width: 100%; }
}

@media (max-width: 480px) {
  .login-card { padding: 24px 16px; }
  .login-logo-icon { width: 48px; height: 48px; font-size: 24px; }
  .login-logo h2 { font-size: 20px; }
  
  .stat-card { padding: 16px; }
  .stat-icon { width: 40px; height: 40px; font-size: 18px; }
  .stat-value { font-size: 20px; }
}
