/* =============== 管理后台基础样式 =============== */
:root {
  --primary: #07C160;
  --primary-dark: #06AD56;
  --bg: #f5f5f5;
  --card-bg: #ffffff;
  --text: #333333;
  --text-light: #666666;
  --border: #e0e0e0;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --danger: #ff4d4f;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

/* 防止输入框缩放 */
input, select, textarea {
  font-size: 16px;
  max-width: 100%;
}

/* 加载屏幕 */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: white;
  z-index: 1000;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

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

/* 错误屏幕 */
.error-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: white;
  z-index: 1000;
}

.error-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.error-screen h2 {
  font-size: 24px;
  margin-bottom: 8px;
}

.error-screen p {
  color: var(--text-light);
  margin-bottom: 24px;
}

/* 管理面板 */
.admin-panel {
  display: flex;
  min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
  width: 240px;
  background: white;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
  font-size: 20px;
  font-weight: 600;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--text);
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
}

.nav-item:hover {
  background: #f5f5f5;
}

.nav-item.active {
  background: rgba(7, 193, 96, 0.1);
  color: var(--primary);
  border-right: 3px solid var(--primary);
}

.nav-item .icon {
  font-size: 20px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.admin-info {
  margin-bottom: 12px;
  font-weight: 500;
}

.back-link {
  display: block;
  color: var(--primary);
  text-decoration: none;
  margin-bottom: 12px;
  font-size: 14px;
}

.logout-btn {
  width: 100%;
  padding: 10px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--danger);
  cursor: pointer;
  font-size: 14px;
}

.logout-btn:hover {
  background: #fff2f0;
}

/* 主内容区 */
.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 24px;
  min-height: 100vh;
  padding-bottom: 80px;
}

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

.content-header h2 {
  font-size: 24px;
  font-weight: 600;
}

.stats {
  display: flex;
  gap: 24px;
}

.stat-item {
  color: var(--text-light);
  font-size: 14px;
}

.stat-item strong {
  color: var(--text);
  font-size: 20px;
  margin-left: 4px;
}

/* 按钮 */
.btn-primary {
  display: inline-block;
  padding: 10px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
}

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

.btn-secondary {
  padding: 10px 20px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

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

/* 数据表格 */
.table-container {
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

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

.data-table th {
  background: #fafafa;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-light);
}

.data-table td {
  font-size: 14px;
}

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

/* 表单卡片 */
.forms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.form-card {
  background: white;
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.form-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

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

.form-customer {
  font-weight: 600;
  font-size: 16px;
}

.form-date {
  font-size: 12px;
  color: var(--text-light);
}

.form-items-count {
  font-size: 14px;
  color: var(--text-light);
}

/* 弹窗 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
}

.modal-content {
  position: relative;
  background: white;
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

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

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-light);
  cursor: pointer;
}

.modal-body {
  padding: 20px;
}

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

.form-info {
  margin-bottom: 16px;
}

.form-info p {
  margin-bottom: 8px;
}

.modal-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-item {
  padding: 12px;
  background: #f8f8f8;
  border-radius: 6px;
  font-size: 14px;
}

/* 标签 */
.tag {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.tag-admin {
  background: rgba(7, 193, 96, 0.1);
  color: var(--primary);
}

.tag-user {
  background: #f0f0f0;
  color: var(--text-light);
}

/* 操作按钮 */
.action-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  margin-right: 8px;
}

.action-btn:hover {
  background: #f5f5f5;
}

/* 底部导航栏 */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  z-index: 100;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 12px;
  color: #999;
  text-decoration: none;
  transition: all 0.2s;
  min-width: 60px;
}

.bottom-nav-item.active {
  color: var(--primary);
}

.bottom-icon {
  font-size: 22px;
  margin-bottom: 2px;
}

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

/* Toast */
.toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.8);
  color: white;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 300;
}

/* 隐藏 */
.hidden {
  display: none !important;
}

/* =============== 货品清单管理样式 =============== */
.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.user-select {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  min-width: 200px;
  background: white;
}

.user-select:focus {
  border-color: var(--primary);
  outline: none;
}

.inventory-content {
  background: white;
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.select-user-hint {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
  font-size: 16px;
}

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

.item-count {
  color: var(--text-light);
}

.btn-add-item {
  padding: 8px 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

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

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

.inventory-table th,
.inventory-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.inventory-table th {
  background: #fafafa;
  font-weight: 600;
  font-size: 13px;
}

.btn-edit,
.btn-delete {
  padding: 5px 12px;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  margin-right: 6px;
}

.btn-edit {
  background: #e6f7ff;
  color: #1890ff;
}

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

/* AI 对话区 */
.ai-chat-section {
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.ai-chat-header {
  padding: 14px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.ai-chat-messages {
  max-height: 250px;
  overflow-y: auto;
  padding: 16px;
  background: #f8f9fa;
}

.ai-message {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.ai-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: var(--primary);
  color: white;
  flex-shrink: 0;
}

.ai-content {
  background: white;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
}

.ai-chat-input {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.ai-chat-input input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 14px;
}

.ai-chat-input button {
  padding: 10px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 20px;
  cursor: pointer;
}

/* =============== 价格走势图样式 =============== */
.chart-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
  padding: 20px;
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-group label {
  font-weight: 600;
}

.items-select {
  max-height: 150px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fafafa;
  overflow-x: hidden;
  word-break: break-all;
}

.item-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  cursor: pointer;
}

.range-buttons {
  display: flex;
  gap: 8px;
}

.range-btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 6px;
  cursor: pointer;
}

.range-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.chart-container {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
  height: 400px;
  margin-bottom: 24px;
}

.chart-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-light);
}

.data-table-container {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.table-wrapper {
  overflow-x: auto;
}

/* =============== 响应式 =============== */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  
  .main-content {
    margin-left: 0;
    padding: 16px;
  }
  
  .content-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .stats {
    flex-direction: column;
    gap: 8px;
  }
  
  .forms-grid {
    grid-template-columns: 1fr;
  }
  
  .data-table th,
  .data-table td {
    padding: 10px 12px;
    font-size: 13px;
  }
  
  .chart-controls {
    grid-template-columns: 1fr;
  }
  
  .chart-container {
    height: 300px;
  }
}

@media (min-width: 769px) {
  .bottom-nav {
    display: none;
  }
}

/* =============== 表单详情价格显示样式 =============== */
.modal-wide {
  max-width: 800px !important;
}

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

.items-table th,
.items-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.items-table th {
  background: #fafafa;
  font-weight: 600;
  color: var(--text-light);
}

.items-table tr:hover {
  background: #f8f8f8;
}

/* 价格缺失标红 */
.price-missing {
  color: var(--danger) !important;
  font-weight: 600;
}

.row-missing {
  background: #fff2f0 !important;
}

.row-missing:hover {
  background: #ffe6e3 !important;
}

/* 总计 */
.form-total {
  margin-top: 16px;
  padding: 12px 16px;
  background: #f0f9ff;
  border-radius: 6px;
  text-align: right;
  font-size: 16px;
  color: var(--text);
}
