/* 果小瑶的工作台 - 粉色主题样式（移动端优化版） */
:root {
  --bg: #fff0f3;
  --panel: #ffffff;
  --primary: #f6a3b8;
  --primary-dark: #e27b98;
  --primary-light: #ffe4eb;
  --accent: #ffcf99;
  --accent2: #c5e5d5;
  --accent3: #c8d8ff;
  --accent4: #e6d5f5;
  --danger: #ff6b7a;
  --success: #6ecf9d;
  --text: #4a3b42;
  --text-light: #8c7a82;
  --radius-sm: 14px;
  --radius: 20px;
  --radius-lg: 26px;
  --shadow: 0 4px 18px rgba(246,163,184,0.16);
  --shadow-soft: 0 2px 10px rgba(74,59,66,0.06);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* 防止iOS橡皮筋滚动时背景露出 */
body::before {
  content: '';
  position: fixed;
  top: -100%;
  left: -100%;
  right: -100%;
  bottom: -100%;
  background: var(--bg);
  z-index: -1;
}

/* ========== 左侧导航栏（桌面端） ========== */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 90px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  z-index: 100;
  box-shadow: 2px 0 12px rgba(246,163,184,0.08);
}

.sidebar-avatar { margin-bottom: 20px; }

.avatar-circle {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  box-shadow: 0 3px 10px rgba(246,163,184,0.3);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 0 7px;
  flex: 1;
}

.nav-item {
  width: 76px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px 8px;
  border: none;
  background: transparent;
  border-radius: 18px;
  cursor: pointer;
  transition: all 0.25s;
  color: var(--text-light);
  font-size: 11px;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.nav-item:active { transform: scale(0.92); opacity: 0.8; }

.nav-item .nav-icon { font-size: 22px; line-height: 1; }
.nav-item .nav-label { font-size: 11px; white-space: nowrap; }

.nav-item.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 3px 12px rgba(246,163,184,0.35);
}

/* ========== 主内容区 ========== */
.main {
  margin-left: 90px;
  min-height: 100vh;
  padding-bottom: 80px;
}

.topbar {
  background: var(--bg);
  padding: 18px 24px 6px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  padding-top: calc(18px + env(safe-area-inset-top, 0px));
}

.topbar-title h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary-dark);
}

.topbar-date {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 2px;
}

.topbar-download {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--panel);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-light);
  box-shadow: var(--shadow-soft);
  transition: all 0.2s;
  touch-action: manipulation;
  flex-shrink: 0;
}
.topbar-download:active { transform: scale(0.9); }

.page-content {
  padding: 16px 24px 24px;
}

/* ========== 欢迎卡片 ========== */
.welcome-card {
  background: linear-gradient(135deg, #ffffff 0%, var(--primary-light) 100%);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.welcome-left { flex: 1; }

.welcome-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 6px;
}

.welcome-date {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 10px;
}

.welcome-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

.welcome-star {
  width: 64px; height: 64px;
  opacity: 0.5;
  flex-shrink: 0;
  margin-left: 16px;
}
.welcome-star svg { width: 100%; height: 100%; }

/* ========== 数据指标卡片 ========== */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.metric-card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 14px 12px;
  box-shadow: var(--shadow-soft);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: transform 0.2s;
}

.metric-icon {
  width: 44px; height: 44px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.metric-info { flex: 1; min-width: 0; }
.metric-label { font-size: 12px; color: var(--text-light); margin-bottom: 2px; }
.metric-value { font-size: 22px; font-weight: 700; color: var(--text); }

.c-pink .metric-icon { background: var(--primary-light); color: var(--primary-dark); }
.c-orange .metric-icon { background: #fff3e0; color: #f57c00; }
.c-green .metric-icon { background: var(--accent2); color: #2e7d32; }
.c-purple .metric-icon { background: var(--accent4); color: #7b1fa2; }
.c-blue .metric-icon { background: var(--accent3); color: #1565c0; }
.c-red .metric-icon { background: #ffebee; color: #c62828; }

.metric-card.span-2 { grid-column: span 2; }

/* ========== 订单列表 ========== */
.section-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

.order-list { display: flex; flex-direction: column; gap: 10px; }

.order-card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-soft);
  border-left: 4px solid var(--primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: transform 0.15s;
}
.order-card:active { transform: scale(0.98); }

.order-card.status-0 { border-left-color: var(--accent); }
.order-card.status-1 { border-left-color: var(--primary); }
.order-card.status-2 { border-left-color: var(--success); }
.order-card.status-3 { border-left-color: var(--text-light); opacity: 0.6; }

.order-info { flex: 1; min-width: 0; }
.order-customer { font-weight: 600; font-size: 15px; }
.order-product { font-size: 13px; color: var(--text-light); margin-top: 2px; }
.order-meta { font-size: 12px; color: var(--text-light); margin-top: 4px; }

.order-actions { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }

.order-status-tag {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.status-tag-0 { background: #fff3e0; color: #f57c00; }
.status-tag-1 { background: var(--primary-light); color: var(--primary-dark); }
.status-tag-2 { background: #e8f5e9; color: #2e7d32; }
.status-tag-3 { background: #f5f5f5; color: #999; }

/* ========== 配方卡片 ========== */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.recipe-card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-soft);
  transition: transform 0.2s;
}

.recipe-name { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.recipe-category {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--primary-light);
  color: var(--primary-dark);
  margin-bottom: 8px;
}
.recipe-steps { font-size: 12px; color: var(--text-light); line-height: 1.5; }

/* ========== 财务 ========== */
.finance-list { display: flex; flex-direction: column; gap: 8px; }

.finance-item {
  background: var(--panel);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  box-shadow: var(--shadow-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.finance-left { flex: 1; }
.finance-category { font-weight: 600; font-size: 14px; }
.finance-desc { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.finance-date { font-size: 11px; color: var(--text-light); }

.finance-amount { font-weight: 700; font-size: 16px; }
.finance-amount.income { color: var(--success); }
.finance-amount.expense { color: var(--danger); }

.finance-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr) !important;
  gap: 12px;
  margin-bottom: 16px;
}

.finance-summary-card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-soft);
  text-align: center;
}
.finance-summary-card .label { font-size: 13px; color: var(--text-light); }
.finance-summary-card .value { font-size: 24px; font-weight: 700; margin-top: 4px; }
.finance-summary-card .value.income { color: var(--success); }
.finance-summary-card .value.expense { color: var(--danger); }

/* ========== 支出分类明细 ========== */
.expense-breakdown {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.expense-breakdown-item { display: flex; align-items: center; gap: 10px; }
.expense-breakdown-left { display: flex; align-items: center; gap: 6px; min-width: 120px; flex-shrink: 0; }
.expense-breakdown-cat { font-size: 13px; font-weight: 600; color: var(--text); }
.expense-breakdown-pct { font-size: 11px; color: var(--text-light); background: var(--primary-light); padding: 1px 6px; border-radius: 8px; }
.expense-breakdown-bar { flex: 1; height: 8px; background: #f5e8ec; border-radius: 4px; overflow: hidden; }
.expense-breakdown-bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-dark)); border-radius: 4px; transition: width 0.4s ease; }
.expense-breakdown-amount { font-size: 13px; font-weight: 700; color: var(--danger); min-width: 70px; text-align: right; flex-shrink: 0; }

/* ========== 备忘录 ========== */
.memo-list { display: flex; flex-direction: column; gap: 8px; }

.memo-item {
  background: var(--panel);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  box-shadow: var(--shadow-soft);
  display: flex;
  align-items: center;
  gap: 10px;
}

.memo-check {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  background: transparent;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  font-size: 14px;
  color: transparent;
  touch-action: manipulation;
  padding: 0;
}
.memo-check:active { transform: scale(0.85); }
.memo-check.done { background: var(--primary); color: #fff; }

.memo-content { flex: 1; font-size: 14px; }
.memo-content.done { text-decoration: line-through; color: var(--text-light); }
.memo-date { font-size: 11px; color: var(--text-light); flex-shrink: 0; }

/* ========== 按钮 ========== */
.btn {
  padding: 10px 18px;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  min-height: 44px;
}
.btn:active { transform: scale(0.95); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 3px 10px rgba(246,163,184,0.3);
}
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 10px; min-height: 36px; }
.btn-ghost { background: var(--primary-light); color: var(--primary-dark); }
.btn-danger { background: #ffebee; color: var(--danger); }

/* ========== 弹窗 ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(74,59,66,0.35);
  z-index: 200;
  display: none;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.modal-overlay.show { display: flex; }

.modal {
  background: var(--panel);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 24px;
  width: 100%;
  max-width: 460px;
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 -4px 30px rgba(74,59,66,0.15);
  animation: slideUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  padding-bottom: calc(24px + var(--safe-bottom));
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.modal h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 16px;
}

/* 弹窗拖拽手柄（移动端视觉提示） */
.modal::before {
  content: '';
  display: block;
  width: 36px;
  height: 4px;
  background: #ddd;
  border-radius: 2px;
  margin: 0 auto 16px;
}

.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #f0dce3;
  border-radius: 12px;
  font-size: 16px;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(246,163,184,0.15);
}
.form-group textarea { resize: vertical; min-height: 80px; }

/* select 下拉箭头 */
.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238c7a82' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
  padding-bottom: var(--safe-bottom);
}

.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }

/* ========== Toast ========== */
.toast-container {
  position: fixed;
  top: calc(20px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--panel);
  color: var(--text);
  padding: 12px 24px;
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(74,59,66,0.18);
  font-size: 14px;
  font-weight: 500;
  animation: slideDown 0.3s;
  pointer-events: auto;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }

@keyframes slideDown { from { transform: translateY(-10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

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

/* ========== 登录页 ========== */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: linear-gradient(160deg, #ffe3ec 0%, #fff7f0 60%, #ffe9d6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-box {
  width: 100%;
  max-width: 340px;
  background: var(--panel);
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(246, 163, 184, 0.25);
  padding: 36px 28px;
  text-align: center;
}
.login-logo { font-size: 48px; }
.login-box h2 { margin: 8px 0 20px; font-size: 20px; color: var(--text); }
.login-box input {
  width: 100%;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1.5px solid #f0dce3;
  border-radius: 12px;
  font-size: 15px;
  outline: none;
  background: #fff;
  color: var(--text);
  box-sizing: border-box;
}
.login-box input:focus { border-color: var(--primary); }
.login-box .btn { width: 100%; padding: 12px; font-size: 16px; }
.login-error { color: #e05a6e; font-size: 13px; min-height: 18px; margin: 8px 0 0; }

/* ========== 搜索/筛选栏 ========== */
.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.filter-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.filter-row input,
.filter-row select {
  padding: 10px 14px;
  border: 1.5px solid #f0dce3;
  border-radius: 12px;
  font-size: 14px;
  outline: none;
  background: var(--panel);
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  min-width: 0;
}
.filter-row input:focus,
.filter-row select:focus { border-color: var(--primary); }
.filter-row .btn { flex-shrink: 0; }

/* ========== 移动端底部 Tab ========== */
.mobile-tabbar {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--panel);
  box-shadow: 0 -2px 12px rgba(246,163,184,0.1);
  z-index: 100;
  padding: 4px 0;
  padding-bottom: calc(4px + var(--safe-bottom));
  border-top: 1px solid rgba(246,163,184,0.1);
}

.mobile-tabbar .tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 2px 4px;
  border: none;
  background: transparent;
  color: var(--text-light);
  font-size: 10px;
  cursor: pointer;
  transition: all 0.2s;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  min-height: 44px;
  justify-content: center;
}
.mobile-tabbar .tab:active { transform: scale(0.9); }
.mobile-tabbar .tab .tab-icon { font-size: 22px; line-height: 1; }
.mobile-tabbar .tab.active {
  color: var(--primary-dark);
  font-weight: 600;
}
.mobile-tabbar .tab.active .tab-icon {
  transform: scale(1.1);
}

/* 今日 Tab 可爱设计 */
.mobile-tabbar .tab-today {
  position: relative;
}
.mobile-tabbar .tab-today .tab-label {
  font-size: 12px;
  font-weight: 700;
}
.mobile-tabbar .tab-today .tab-icon {
  font-size: 24px;
  animation: gentle-bounce 2s ease-in-out infinite;
}
.mobile-tabbar .tab-today.active .tab-icon {
  animation: bounce-spin 1.5s ease-in-out infinite;
}
@keyframes gentle-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}
@keyframes bounce-spin {
  0%, 100% { transform: scale(1.2) rotate(0deg); }
  25% { transform: scale(1.2) rotate(-5deg); }
  75% { transform: scale(1.2) rotate(5deg); }
}

/* ========== 响应式 - 平板 ========== */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding-bottom: calc(70px + var(--safe-bottom)); }
  .mobile-tabbar { display: flex; }

  .topbar { padding: 10px 14px 4px; }
  .topbar-title h1 { font-size: 18px; }
  .topbar-date { font-size: 12px; }
  .page-content { padding: 10px 14px 14px; }

  .metric-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .metric-card.span-2 { grid-column: span 2; }
  .metric-value { font-size: 18px; }
  .metric-icon { width: 38px; height: 38px; font-size: 18px; }

  .welcome-card { padding: 14px 16px; flex-wrap: wrap; }
  .welcome-title { font-size: 18px; }
  .welcome-star { display: none; }
  .welcome-badge { font-size: 12px; padding: 4px 10px; }

  .finance-summary { grid-template-columns: 1fr !important; gap: 10px; }

  .order-card { flex-direction: column; align-items: flex-start; gap: 8px; }
  .order-actions { width: 100%; justify-content: flex-end; flex-wrap: wrap; }

  .filter-row:last-child .btn { flex: 1; }

  .recipe-grid { grid-template-columns: 1fr; }

  .modal { width: 100%; max-width: none; border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: 20px; max-height: 90vh; }

  .form-row { flex-direction: column; gap: 0; }

  .expense-breakdown-item { flex-wrap: wrap; }
  .expense-breakdown-left { min-width: 100px; }
  .expense-breakdown-amount { min-width: 60px; }
}

/* ========== 响应式 - 手机 ========== */
@media (max-width: 480px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-value { font-size: 16px; }
  .metric-label { font-size: 11px; }
  .metric-card { padding: 10px 8px; gap: 8px; }
  .metric-icon { width: 34px; height: 34px; font-size: 16px; border-radius: 10px; }

  .topbar-title h1 { font-size: 16px; }
  .order-customer { font-size: 14px; }
  .order-product { font-size: 12px; }
  .section-title { font-size: 15px; }

  .welcome-card { padding: 12px 14px; border-radius: 18px; }
  .welcome-title { font-size: 16px; margin-bottom: 4px; }
  .welcome-date { font-size: 12px; margin-bottom: 8px; }

  .order-card { padding: 12px; border-radius: 16px; }
  .order-status-tag { font-size: 10px; padding: 2px 8px; }

  .btn-sm { padding: 5px 10px; font-size: 11px; min-height: 32px; }

  .finance-summary-card { padding: 14px 10px; }
  .finance-summary-card .value { font-size: 20px; }
}
