/* ========== 基础变量 ========== */
:root {
  --blue-50: #E3F2FD;
  --blue-100: #BBDEFB;
  --blue-200: #90CAF9;
  --blue-300: #64B5F6;
  --blue-400: #42A5F5;
  --pink-50: #FCE4EC;
  --pink-100: #F8BBD0;
  --pink-200: #F48FB1;
  --pink-300: #F06292;
  --gray-50: #FAFAFA;
  --gray-100: #F5F5F5;
  --gray-200: #EEEEEE;
  --gray-300: #E0E0E0;
  --gray-400: #BDBDBD;
  --gray-600: #757575;
  --gray-800: #424242;
  --white: #FFFFFF;
  --shadow-sm: 0 2px 8px rgba(100, 181, 246, 0.15);
  --shadow-md: 0 4px 16px rgba(100, 181, 246, 0.2);
  --shadow-lg: 0 8px 32px rgba(100, 181, 246, 0.25);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --sidebar-width: 220px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: linear-gradient(135deg, var(--blue-50) 0%, var(--pink-50) 100%);
  min-height: 100vh;
  color: var(--gray-800);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ========== 应用布局 ========== */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* ========== 左侧导航 ========== */
.sidebar {
  width: var(--sidebar-width);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid rgba(255, 255, 255, 0.5);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 200;
  padding: 20px 12px;
  transition: transform 0.3s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 20px;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 12px;
}

.logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--blue-200), var(--blue-300));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: var(--shadow-sm);
}

.sidebar-title {
  font-size: 15px;
  font-weight: 600;
  background: linear-gradient(135deg, var(--blue-400), var(--pink-300));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-items {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  width: 100%;
}

.nav-item:hover {
  background: var(--blue-50);
  color: var(--blue-400);
}

.nav-item.active {
  background: linear-gradient(135deg, var(--blue-100), var(--pink-100));
  color: var(--blue-400);
  font-weight: 500;
}

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

.sidebar-footer {
  padding-top: 12px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-footer .connection-status {
  justify-content: flex-start;
  padding: 6px 12px;
}

.settings-nav {
  margin-top: 4px;
}

/* ========== 移动端顶栏 ========== */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--gray-200);
  align-items: center;
  padding: 0 16px;
  z-index: 100;
  gap: 12px;
}

.menu-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  font-size: 18px;
  cursor: pointer;
}

.mobile-title {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  background: linear-gradient(135deg, var(--blue-400), var(--pink-300));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 150;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
  display: block;
  opacity: 1;
}

/* ========== 主内容区 ========== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 24px;
  max-width: 1100px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

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

.page-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--gray-800);
}

.page-actions {
  display: flex;
  gap: 8px;
}

.view-btn {
  padding: 6px 14px;
  border: 1px solid var(--gray-200);
  background: var(--white);
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  color: var(--gray-600);
  transition: all 0.2s ease;
}

.view-btn.active {
  background: linear-gradient(135deg, var(--blue-200), var(--pink-200));
  color: white;
  border-color: transparent;
}

.today-badge {
  padding: 6px 14px;
  background: var(--blue-50);
  border-radius: 20px;
  font-size: 13px;
  color: var(--blue-400);
}

/* ========== 连接状态 ========== */
.connection-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.connection-status.online {
  background: rgba(76, 175, 80, 0.1);
  color: #4CAF50;
}

.connection-status.offline {
  background: rgba(158, 158, 158, 0.1);
  color: var(--gray-600);
}

.connection-status.syncing {
  background: rgba(33, 150, 243, 0.1);
  color: #2196F3;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.connection-status.online .status-dot {
  background: #4CAF50;
  animation: pulse-green 2s infinite;
}

.connection-status.offline .status-dot {
  background: #9E9E9E;
}

.connection-status.syncing .status-dot {
  background: #2196F3;
  animation: pulse-blue 1s infinite;
}

@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(76, 175, 80, 0); }
}

@keyframes pulse-blue {
  0%, 100% { box-shadow: 0 0 0 0 rgba(33, 150, 243, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(33, 150, 243, 0); }
}

/* ========== 统计卡片 ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255, 255, 255, 0.8);
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card.blue {
  background: linear-gradient(135deg, rgba(227, 242, 253, 0.95), rgba(187, 222, 251, 0.8));
}

.stat-card.pink {
  background: linear-gradient(135deg, rgba(252, 228, 236, 0.95), rgba(248, 187, 208, 0.8));
}

.stat-label {
  font-size: 13px;
  color: var(--gray-600);
}

.stat-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--gray-800);
  line-height: 1;
}

/* ========== 卡片 ========== */
.card {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255, 255, 255, 0.8);
  margin-bottom: 16px;
}

.card.blue {
  background: linear-gradient(135deg, rgba(227, 242, 253, 0.9), rgba(187, 222, 251, 0.7));
}

.card.pink {
  background: linear-gradient(135deg, rgba(252, 228, 236, 0.9), rgba(248, 187, 208, 0.7));
}

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

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  background: rgba(255, 255, 255, 0.6);
}

.section-count {
  font-size: 13px;
  color: var(--gray-600);
  background: rgba(255, 255, 255, 0.6);
  padding: 2px 10px;
  border-radius: 12px;
}

/* ========== 月历 ========== */
.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}

.calendar-weekdays span {
  text-align: center;
  font-size: 12px;
  color: var(--gray-600);
  font-weight: 500;
  padding: 4px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-day {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  padding: 6px;
  background: rgba(255, 255, 255, 0.5);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.calendar-day:hover {
  background: rgba(255, 255, 255, 0.9);
}

.calendar-day.today {
  background: linear-gradient(135deg, var(--blue-200), var(--pink-200));
  box-shadow: var(--shadow-sm);
}

.calendar-day.today .day-num {
  color: white;
  font-weight: 600;
}

.calendar-day.other-month {
  opacity: 0.4;
}

.day-num {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-800);
}

.day-items {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 2px;
  overflow: hidden;
}

.day-item {
  font-size: 10px;
  padding: 1px 4px;
  background: var(--blue-100);
  border-radius: 3px;
  color: var(--blue-400);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.day-item.event {
  background: var(--pink-100);
  color: var(--pink-300);
}

.day-more {
  font-size: 10px;
  color: var(--gray-600);
  padding: 0 4px;
}

/* ========== 计划列表 ========== */
.plans-sections {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.plan-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 350px;
  overflow-y: auto;
}

.plan-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.plan-item:hover {
  background: rgba(255, 255, 255, 0.95);
}

.plan-checkbox {
  width: 20px;
  height: 20px;
  border: 2px solid var(--blue-200);
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  transition: all 0.2s ease;
}

.plan-checkbox.checked {
  background: var(--blue-300);
  border-color: var(--blue-300);
}

.plan-checkbox.checked::after {
  content: '✓';
  color: white;
  font-size: 13px;
  font-weight: bold;
}

.plan-content {
  flex: 1;
  min-width: 0;
}

.plan-text {
  font-size: 14px;
  color: var(--gray-800);
  outline: none;
  word-break: break-word;
}

.plan-item.completed .plan-text {
  text-decoration: line-through;
  color: var(--gray-400);
}

.plan-meta {
  font-size: 11px;
  color: var(--gray-600);
  margin-top: 4px;
  display: flex;
  gap: 8px;
}

.plan-delete {
  opacity: 0;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--gray-400);
  font-size: 16px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.plan-item:hover .plan-delete {
  opacity: 1;
}

.plan-delete:hover {
  color: #F44336;
}

.add-plan-btn {
  width: 100%;
  padding: 14px;
  border: 2px dashed var(--blue-200);
  background: rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-md);
  color: var(--blue-400);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 8px;
}

.add-plan-btn:hover {
  border-color: var(--blue-300);
  background: rgba(144, 202, 249, 0.1);
}

/* ========== 事件列表 ========== */
.events-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.event-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--pink-300);
}

.event-date {
  text-align: center;
  min-width: 50px;
}

.event-day {
  font-size: 20px;
  font-weight: 600;
  color: var(--pink-300);
  line-height: 1;
}

.event-month {
  font-size: 11px;
  color: var(--gray-600);
}

.event-info {
  flex: 1;
}

.event-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-800);
}

.event-time, .event-note {
  font-size: 12px;
  color: var(--gray-600);
  margin-top: 2px;
}

/* ========== 财富自由 ========== */
.wealth-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  background: rgba(255, 255, 255, 0.8);
  transition: border-color 0.2s ease;
  font-family: inherit;
}

.form-input:focus {
  border-color: var(--blue-300);
}

.wealth-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
}

.wealth-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-sm);
}

.wealth-type {
  font-size: 16px;
}

.wealth-amount {
  font-weight: 600;
  font-size: 15px;
}

.wealth-amount.income { color: #4CAF50; }
.wealth-amount.expense { color: #F44336; }
.wealth-amount.asset { color: var(--blue-400); }

.wealth-note {
  flex: 1;
  font-size: 13px;
  color: var(--gray-600);
}

.wealth-date {
  font-size: 11px;
  color: var(--gray-400);
}

/* ========== 显化清单 ========== */
.manifest-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.manifest-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.8), rgba(252, 228, 236, 0.5));
  border-radius: var(--radius-sm);
  border: 1px solid rgba(244, 143, 177, 0.2);
}

.manifest-icon {
  font-size: 20px;
}

.manifest-text {
  flex: 1;
  font-size: 14px;
  line-height: 1.7;
  color: var(--gray-800);
}

.manifest-item.fulfilled {
  opacity: 0.7;
}

.manifest-item.fulfilled .manifest-text {
  text-decoration: line-through;
  color: var(--gray-400);
}

.manifest-date {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 4px;
}

/* ========== 弹窗 ========== */
.modal, .settings-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  padding: 20px;
}

.modal.show, .settings-modal.show {
  opacity: 1;
  visibility: visible;
}

.modal-content, .settings-content {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.modal.show .modal-content,
.settings-modal.show .settings-content {
  transform: scale(1);
}

.modal-title, .settings-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--gray-800);
}

.form-group {
  margin-bottom: 14px;
}

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

.form-hint {
  font-size: 11px;
  color: var(--gray-600);
  margin-top: 4px;
  line-height: 1.5;
}

.modal-actions, .settings-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--blue-300), var(--blue-400));
  color: white;
}

.btn-primary:hover {
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-600);
}

.btn-secondary:hover {
  background: var(--gray-200);
}

/* ========== 保存提示 ========== */
.save-indicator {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  color: var(--gray-600);
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
  z-index: 99;
}

.save-indicator.show {
  opacity: 1;
  transform: translateY(0);
}

.save-indicator .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4CAF50;
}

/* ========== 挂件视图 ========== */
.widget-mode .stats-grid {
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.widget-mode .stat-card {
  padding: 10px 8px;
  gap: 4px;
}

.widget-mode .stat-label {
  font-size: 11px;
}

.widget-mode .stat-value {
  font-size: 20px;
}

.widget-mode .calendar-day {
  padding: 3px;
}

.widget-mode .day-num {
  font-size: 11px;
}

.widget-mode .day-items {
  display: none;
}

.widget-mode .card {
  padding: 14px;
}

.widget-mode .card-title {
  font-size: 14px;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

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

  .mobile-header {
    display: flex;
  }

  .main-content {
    margin-left: 0;
    padding: 72px 16px 20px;
  }

  .plans-sections {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

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

  .form-row {
    grid-template-columns: 1fr;
  }

  .widget-mode .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .calendar-grid {
    gap: 2px;
  }

  .calendar-day {
    padding: 3px;
  }

  .day-num {
    font-size: 11px;
  }
}

/* 滚动条 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--blue-200);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--blue-300);
}
