/* ========================================
   马上有钱 | 摆摊记账 — 全局样式
   暖米色柔和配色 · 圆角卡片 · 移动端优先
   ======================================== */

:root {
  /* 主色调 - 暖米色系 */
  --bg-primary: #FDF8F0;
  --bg-secondary: #FAF3E8;
  --bg-card: #FFFFFF;
  --bg-card-warm: #FFFBF5;
  --bg-hover: #F5EDE0;

  /* 文字色 */
  --text-primary: #5C4A3A;
  --text-secondary: #8B7355;
  --text-light: #B0A090;
  --text-white: #FFFFFF;

  /* 强调色 */
  --accent-orange: #E8956B;
  --accent-orange-light: #F4B894;
  --accent-orange-bg: #FDF0E6;
  --accent-purple: #A78BFA;
  --accent-purple-light: #C4B5FD;
  --accent-purple-bg: #F0EBFF;
  --accent-green: #7BC47F;
  --accent-red: #E8746B;

  /* 边框 */
  --border-color: #E8DDD0;
  --border-light: #F0E8DC;

  /* 阴影 */
  --shadow-sm: 0 1px 3px rgba(139, 115, 85, 0.08);
  --shadow-md: 0 2px 8px rgba(139, 115, 85, 0.10);
  --shadow-lg: 0 4px 16px rgba(139, 115, 85, 0.12);

  /* 圆角 */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* 间距 */
  --sidebar-width: 220px;
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ========== 侧边栏 ========== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s ease;
  z-index: 100;
}

.sidebar-header {
  padding: 24px 20px 20px;
  text-align: center;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-logo {
  font-size: 40px;
  margin-bottom: 8px;
}

.sidebar-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 1px;
}

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

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  margin-bottom: 4px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-orange);
  color: var(--text-white);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.nav-icon {
  font-size: 18px;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.nav-text {
  white-space: nowrap;
}

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

.version-tag {
  font-size: 11px;
  color: var(--text-light);
  text-align: center;
}

/* ========== 主内容区 ========== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
}

.mobile-header {
  display: none;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
}

.menu-toggle {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  width: 28px;
  height: 22px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.menu-toggle span {
  display: block;
  width: 100%;
  height: 3px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all 0.3s;
}

.mobile-title {
  margin-left: 16px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

.page-container {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-lg);
  -webkit-overflow-scrolling: touch;
}

/* ========== 卡片 ========== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--spacing-md);
  border: 1px solid var(--border-light);
}

.card-warm {
  background: var(--bg-card-warm);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--spacing-md);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .icon {
  font-size: 18px;
}

/* ========== 页面标题 ========== */
.page-header {
  margin-bottom: var(--spacing-lg);
}

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

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

/* ========== 标语 ========== */
.slogan-banner {
  background: linear-gradient(135deg, var(--accent-orange-light), var(--accent-orange));
  border-radius: var(--radius-lg);
  padding: 14px 20px;
  margin-bottom: var(--spacing-md);
  text-align: center;
  color: white;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.5px;
  box-shadow: var(--shadow-sm);
}

.slogan-bottom {
  text-align: center;
  padding: 20px 16px;
  margin-top: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  font-style: italic;
  background: var(--bg-card-warm);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--accent-orange-light);
}

/* ========== 日历 ========== */
.calendar-wrapper {
  margin-bottom: var(--spacing-md);
}

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

.calendar-month-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.calendar-nav-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.calendar-nav-btn:hover {
  background: var(--accent-orange-bg);
  border-color: var(--accent-orange);
  color: var(--accent-orange);
}

.calendar-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 2px;
  scrollbar-width: thin;
}

.calendar-scroll::-webkit-scrollbar {
  height: 4px;
}

.calendar-scroll::-webkit-scrollbar-thumb {
  background: var(--accent-orange-light);
  border-radius: 2px;
}

.cal-day {
  flex-shrink: 0;
  width: 48px;
  height: 60px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 2px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 12px;
  color: var(--text-secondary);
}

.cal-day:hover {
  border-color: var(--accent-orange-light);
}

.cal-day .cal-weekday {
  font-size: 10px;
  color: var(--text-light);
  margin-bottom: 2px;
}

.cal-day .cal-num {
  font-size: 16px;
  font-weight: 600;
}

.cal-day.today {
  background: var(--accent-orange-bg);
}

.cal-day.selected {
  background: var(--accent-orange);
  color: white;
  border-color: var(--accent-orange);
}

.cal-day.selected .cal-weekday {
  color: rgba(255,255,255,0.8);
}

/* ========== 数据展示 ========== */
.data-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--spacing-md);
}

.data-item {
  text-align: center;
  padding: 16px 12px;
  background: var(--bg-card-warm);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

.data-label {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 6px;
}

.data-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

.data-value.income {
  color: var(--accent-purple);
}

.data-value.expense {
  color: var(--accent-orange);
}

.data-value.profit {
  color: var(--accent-green);
}

.data-value.total {
  font-size: 28px;
  color: var(--accent-orange);
}

.data-unit {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-light);
}

/* ========== 表单元素 ========== */
.form-group {
  margin-bottom: var(--spacing-md);
}

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

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  font-size: 14px;
  color: var(--text-primary);
  transition: all 0.2s;
  font-family: inherit;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent-orange);
  box-shadow: 0 0 0 3px var(--accent-orange-bg);
}

.form-textarea {
  resize: vertical;
  min-height: 60px;
}

.form-row {
  display: flex;
  gap: var(--spacing-md);
}

.form-row > .form-group {
  flex: 1;
}

/* ========== 按钮 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent-orange);
  color: white;
}

.btn-primary:hover {
  background: #D8855B;
}

.btn-purple {
  background: var(--accent-purple);
  color: white;
}

.btn-purple:hover {
  background: #9B7AEA;
}

.btn-outline {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-outline:hover {
  border-color: var(--accent-orange);
  color: var(--accent-orange);
}

.btn-danger {
  background: var(--accent-red);
  color: white;
}

.btn-danger:hover {
  background: #D8645B;
}

.btn-success {
  background: var(--accent-green);
  color: white;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

/* ========== 表格 ========== */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
}

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

table.data-table th {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-color);
}

table.data-table th:first-child {
  border-radius: var(--radius-md) 0 0 0;
}

table.data-table th:last-child {
  border-radius: 0 var(--radius-md) 0 0;
}

table.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
}

table.data-table tr:last-child td {
  border-bottom: none;
}

table.data-table tr:hover td {
  background: var(--bg-card-warm);
}

table.data-table input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 13px;
  color: var(--text-primary);
  font-family: inherit;
  text-align: center;
}

table.data-table input:focus {
  outline: none;
  border-color: var(--accent-orange);
  background: var(--bg-card);
  box-shadow: 0 0 0 2px var(--accent-orange-bg);
}

.table-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 2px 4px;
  border-radius: 4px;
  transition: all 0.2s;
}

.table-action-btn:hover {
  background: var(--bg-hover);
}

/* ========== 标签 ========== */
.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.tag-income {
  background: var(--accent-purple-bg);
  color: var(--accent-purple);
}

.tag-expense {
  background: var(--accent-orange-bg);
  color: var(--accent-orange);
}

.tag-other {
  background: #F0F0F0;
  color: #999;
}

/* ========== Toast 提示 ========== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text-primary);
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius-xl);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  max-width: 90%;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ========== 遮罩层 ========== */
.overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.3);
  z-index: 99;
}

.overlay.show {
  display: block;
}

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

/* ========== 库存预警 ========== */
.low-stock {
  color: var(--accent-red) !important;
  font-weight: 600;
}

.low-stock-row {
  background: #FFF5F5 !important;
}

.low-stock-alert {
  background: #FFF0EE;
  border: 1px solid var(--accent-red);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  margin-bottom: var(--spacing-sm);
  color: var(--accent-red);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

/* ========== 分区标题 ========== */
.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--spacing-md);
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ========== 提醒文案 ========== */
.reminder {
  background: var(--accent-orange-bg);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  text-align: center;
  color: var(--accent-orange);
  font-size: 14px;
  font-weight: 500;
  margin-top: var(--spacing-md);
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 240px;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-header {
    display: flex;
  }

  .page-container {
    padding: var(--spacing-md);
    padding-bottom: 80px;
  }

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

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

  .data-value.total {
    font-size: 24px;
  }

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

  .card {
    padding: var(--spacing-md);
  }

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

  table.data-table {
    font-size: 12px;
  }

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

  .cal-day {
    width: 42px;
    height: 54px;
  }
}

@media (max-width: 380px) {
  .data-grid {
    grid-template-columns: 1fr;
  }
}

/* ========== 工具类 ========== */
flex { display: flex; }
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.wrap { flex-wrap: wrap; }
