/* ===== 基础重置 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.5;
  min-height: 100vh;
}
a { text-decoration: none; color: inherit; }
button { border: none; background: none; cursor: pointer; font-family: inherit; }
input, select { font-family: inherit; font-size: inherit; }

/* ===== 微信绿色主题变量 ===== */
:root {
  --primary: #07c160;
  --primary-dark: #06ad56;
  --primary-light: #e8f5e9;
  --danger: #fa5151;
  --warning: #ffc300;
  --info: #10aeff;
  --bg: #f5f5f5;
  --bg-white: #ffffff;
  --text: #333333;
  --text-secondary: #666666;
  --text-muted: #999999;
  --border: #e5e5e5;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --radius: 8px;
  --radius-lg: 12px;
}

/* ===== 布局 ===== */
.container { max-width: 640px; margin: 0 auto; padding: 0 16px; }
.page { padding-bottom: 32px; }

/* ===== 头部 ===== */
.header {
  background: var(--primary);
  color: #fff;
  padding: 16px;
  text-align: center;
  position: relative;
}
.header h1 { font-size: 18px; font-weight: 600; }
.header .subtitle { font-size: 12px; opacity: 0.85; margin-top: 2px; }
.header .back-btn {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  color: #fff; font-size: 14px;
}
.header .admin-link {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  color: #fff; font-size: 13px; padding: 4px 10px;
  background: rgba(255,255,255,0.2); border-radius: 20px;
}

/* ===== 卡片 ===== */
.card {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin: 12px 0;
  overflow: hidden;
}
.card-header {
  padding: 16px 16px 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  display: flex; align-items: center; justify-content: space-between;
}
.card-body { padding: 12px 16px 16px; }

/* ===== 当前价格展示 ===== */
.price-display {
  text-align: center;
  padding: 24px 16px;
  background: linear-gradient(135deg, #07c160 0%, #05a350 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  margin: 12px 0;
}
.price-display .label { font-size: 14px; opacity: 0.9; }
.price-display .price {
  font-size: 48px;
  font-weight: 700;
  margin: 8px 0;
  letter-spacing: -1px;
}
.price-display .unit { font-size: 16px; font-weight: 400; }
.price-display .date { font-size: 13px; opacity: 0.85; }
.price-display .trend {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 12px;
  background: rgba(255,255,255,0.2);
  border-radius: 20px;
  font-size: 13px;
}

/* ===== 日期选择器 ===== */
.date-picker {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  background: var(--bg-white);
  margin: 12px 0;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.date-picker label { font-size: 14px; color: var(--text-secondary); white-space: nowrap; }
.date-picker input[type="date"] {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  -webkit-appearance: none;
}
.date-picker .btn {
  padding: 8px 16px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
  font-size: 14px;
  white-space: nowrap;
}

/* ===== 图表容器 ===== */
.chart-container {
  position: relative;
  height: 260px;
  width: 100%;
}

/* ===== 数据表格 ===== */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  padding: 12px 10px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
  font-size: 13px;
  position: sticky;
  top: 0;
}
tr:hover { background: #fafafa; }
.trend-up { color: var(--danger); }
.trend-down { color: var(--primary); }
.trend-flat { color: var(--text-muted); }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
  gap: 4px;
}
.btn:active { opacity: 0.85; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #333; }
.btn-info { background: var(--info); color: #fff; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ===== 表单 ===== */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}
.form-input, .form-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--bg-white);
  -webkit-appearance: none;
}
.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
}
.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== 登录页 ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login-box {
  width: 100%;
  max-width: 360px;
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 32px 24px;
}
.login-box .logo {
  text-align: center;
  margin-bottom: 24px;
}
.login-box .logo-icon {
  width: 56px; height: 56px;
  background: var(--primary);
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 24px;
}
.login-box h2 { text-align: center; font-size: 18px; margin-bottom: 20px; }
.login-box .error {
  background: #fff2f0;
  color: var(--danger);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 12px;
  display: none;
}
.login-box .error.show { display: block; }

/* ===== 后台导航 ===== */
.admin-nav {
  display: flex;
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin: 12px 0;
  overflow: hidden;
}
.admin-nav a {
  flex: 1;
  text-align: center;
  padding: 12px;
  font-size: 14px;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
}
.admin-nav a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ===== 统计卡片 ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 12px 0;
}
.stat-card {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 16px;
  text-align: center;
}
.stat-card .value {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}
.stat-card .label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== 操作栏 ===== */
.action-bar {
  display: flex;
  gap: 8px;
  margin: 12px 0;
  flex-wrap: wrap;
}

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ===== Toast 提示 ===== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 14px;
  color: #fff;
  z-index: 9999;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.toast-success { background: var(--primary); }
.toast-error { background: var(--danger); }

/* ===== 模态框 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 16px; }
.modal-close { font-size: 20px; color: var(--text-muted); cursor: pointer; }
.modal-body { padding: 16px; }
.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ===== 开关 ===== */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #ccc;
  border-radius: 28px;
  transition: 0.3s;
}
.switch-slider::before {
  content: "";
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.3s;
}
.switch input:checked + .switch-slider { background: var(--primary); }
.switch input:checked + .switch-slider::before { transform: translateX(20px); }

/* ===== 分页 ===== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  font-size: 14px;
}
.pagination a, .pagination span {
  padding: 6px 12px;
  border-radius: var(--radius);
  min-width: 36px;
  text-align: center;
}
.pagination a { background: var(--bg-white); border: 1px solid var(--border); }
.pagination a.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .disabled { color: var(--text-muted); cursor: not-allowed; }

/* ===== 页脚 ===== */
.footer {
  text-align: center;
  padding: 20px 16px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== 响应式 ===== */
@media (min-width: 768px) {
  .container { max-width: 800px; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}
