* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  background-attachment: fixed;
  padding-bottom: 60px;
}

.page-wrapper {
  max-width: 800px;
  margin: 0 auto;
}

.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  padding: 24px 16px;
  text-align: center;
  font-size: 24px;
  font-weight: bold;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  letter-spacing: 0.5px;
}

.nav-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  display: flex;
  border-top: 1px solid #eee;
  max-width: 800px;
  margin: 0 auto;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
}

.nav-bar a {
  flex: 1;
  padding: 12px;
  text-align: center;
  text-decoration: none;
  color: #666;
  font-size: 14px;
  transition: all 0.3s;
  position: relative;
}

.nav-bar a:hover {
  color: #1890ff;
  background: #f0f7ff;
}

.nav-bar a.active {
  color: #1890ff;
  font-weight: 600;
}

.nav-bar a.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 3px;
  background: #1890ff;
  border-radius: 3px 3px 0 0;
}

.stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 16px;
}

@media (min-width: 600px) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

.card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  padding: 20px;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  transition: transform 0.3s, box-shadow 0.3s;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
}

.stat-card {
  padding: 24px;
  background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.85) 100%);
}

.stat-label {
  font-size: 14px;
  color: #666;
  margin-bottom: 16px;
  font-weight: 600;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  font-size: 15px;
  gap: 12px;
}

.stat-item span:first-child {
  flex-shrink: 0;
}

.stat-item span:last-child {
  text-align: right;
}

.stat-item.balance {
  border-top: 1px solid #f0f0f0;
  margin-top: 8px;
  padding-top: 16px;
  font-weight: 600;
  font-size: 16px;
}

.chart-card {
  margin: 16px;
}

.chart-card h3 {
  font-size: 16px;
  margin-bottom: 16px;
  color: #333;
}

.month-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 16px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(240,240,240,0.5);
}

.current-month {
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.nav-btn {
  padding: 10px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(102,126,234,0.3);
  transition: all 0.3s;
  width: 40px;
  height: 40px;
}

.nav-btn:hover:not(:disabled) {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(102,126,234,0.4);
}

.nav-btn:disabled {
  background: linear-gradient(135deg, #d9d9d9 0%, #bfbfbf 100%);
  cursor: not-allowed;
  opacity: 0.5;
  box-shadow: none;
}

.nav-btn svg {
  display: block;
}

.current-month {
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.month-selector {
  padding: 16px;
  background: #fff;
}

.month-selector select {
  width: 100%;
  padding: 8px;
  font-size: 16px;
}

.stats-summary {
  padding: 20px 12px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  display: flex;
  justify-content: space-around;
  gap: 12px;
  border-bottom: 1px solid rgba(240,240,240,0.5);
}

.stats-summary .stat-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stats-summary .stat-label {
  font-size: 13px;
  color: #999;
  margin-bottom: 8px;
}

.stats-summary .stat-value {
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.day-group {
  margin: 12px 16px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  border: 1px solid rgba(255,255,255,0.18);
}

.day-header {
  padding: 10px 12px;
  background: #fafafa;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #f0f0f0;
  flex-wrap: wrap;
  gap: 8px;
}

.day-date {
  font-weight: 600;
  color: #333;
  font-size: 14px;
  flex-shrink: 0;
}

.day-stats {
  display: flex;
  gap: 12px;
  font-size: 12px;
  flex-wrap: wrap;
}

.record-item {
  border-bottom: 1px solid #f0f0f0;
  position: relative;
  overflow: hidden;
}

.record-item.swiped .record-main {
  transform: translateX(-140px);
}

.record-main {
  padding: 14px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  position: relative;
  z-index: 1;
  transition: transform 0.3s;
  touch-action: pan-y;
}

.record-item:last-child {
  border-bottom: none;
}

.record-icon {
  font-size: 32px;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.record-info {
  flex: 1;
  min-width: 0;
}

.record-category {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-category.income {
  color: #52c41a;
}

.record-category.expense {
  color: #f5222d;
}

.record-desc {
  font-size: 13px;
  color: #999;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-amount {
  font-size: 16px;
  font-weight: 600;
  flex-shrink: 0;
  text-align: right;
  margin-left: auto;
}

.record-amount.income {
  color: #52c41a;
}

.record-amount.expense {
  color: #f5222d;
}

.record-actions {
  display: flex;
  gap: 0;
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 140px;
}

.record-item button {
  flex: 1;
  padding: 0;
  color: #fff;
  border: none;
  border-radius: 0;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}

.edit-btn {
  background: linear-gradient(135deg, #1890ff 0%, #096dd9 100%);
  transition: all 0.3s;
}

.edit-btn:hover {
  background: linear-gradient(135deg, #40a9ff 0%, #1890ff 100%);
}

.delete-btn {
  background: linear-gradient(135deg, #ff4d4f 0%, #cf1322 100%);
  transition: all 0.3s;
}

.delete-btn:hover {
  background: linear-gradient(135deg, #ff7875 0%, #ff4d4f 100%);
}

.income {
  color: #52c41a;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(82,196,26,0.2);
}

.expense {
  color: #f5222d;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(245,34,45,0.2);
}


.form-container {
  padding: 16px;
}

.type-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.type-selector button {
  flex: 1;
  padding: 12px;
  border: 2px solid rgba(102,126,234,0.3);
  background: rgba(255,255,255,0.9);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  font-weight: 500;
}

.type-selector button.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(102,126,234,0.3);
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

@media (max-width: 400px) {
  .category-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.category-btn {
  padding: 12px 8px;
  border: 2px solid rgba(102,126,234,0.2);
  background: rgba(255,255,255,0.9);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  word-break: keep-all;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.3s;
}

.category-btn:hover {
  border-color: rgba(102,126,234,0.5);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102,126,234,0.15);
}

.category-btn.active {
  background: linear-gradient(135deg, rgba(102,126,234,0.15) 0%, rgba(118,75,162,0.15) 100%);
  border-color: #667eea;
  font-weight: 600;
}

.more-btn {
  background: linear-gradient(135deg, rgba(102,126,234,0.1) 0%, rgba(118,75,162,0.1) 100%);
  border-color: rgba(102,126,234,0.4);
  font-weight: 600;
  color: #667eea;
}

.more-btn:hover {
  background: linear-gradient(135deg, rgba(102,126,234,0.2) 0%, rgba(118,75,162,0.2) 100%);
  border-color: #667eea;
}

.form-container input {
  width: 100%;
  padding: 14px;
  margin-bottom: 12px;
  border: 2px solid rgba(102,126,234,0.2);
  border-radius: 8px;
  font-size: 16px;
  background: rgba(255,255,255,0.9);
  transition: all 0.3s;
}

.form-container input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102,126,234,0.1);
}

.save-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(102,126,234,0.3);
  transition: all 0.3s;
  font-weight: 600;
}

.save-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102,126,234,0.4);
}

@media (max-width: 600px) {
  .category-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .header {
    font-size: 18px;
    padding: 16px;
  }

  .chart-card {
    margin: 12px;
  }

  .chart-card h3 {
    font-size: 15px;
  }

  .current-month {
    font-size: 16px;
  }

  .nav-btn {
    padding: 6px 12px;
    font-size: 13px;
  }
}

.category-stats {
  margin: 16px;
  background: #fff;
  border-radius: 8px;
  padding: 16px;
}

.category-stats h3 {
  margin-bottom: 12px;
  font-size: 16px;
}

.category-item {
  display: flex;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}

.category-item:last-child {
  border-bottom: none;
}

.category-name {
  flex: 1;
}

.category-amount {
  margin-right: 12px;
  font-weight: bold;
}

.category-percent {
  color: #999;
  font-size: 14px;
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Skeleton loading */
.skeleton {
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  background: linear-gradient(90deg, rgba(255,255,255,.3) 25%, rgba(255,255,255,.5) 50%, rgba(255,255,255,.3) 75%);
  background-size: 200% 100%;
  border-radius: 8px;
}

@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-card {
  background: rgba(255,255,255,.15);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 20px;
  margin: 12px 16px;
  border: 1px solid rgba(255,255,255,.1);
}

.skeleton-line {
  height: 16px;
  margin-bottom: 12px;
  border-radius: 4px;
}

.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 65%; }
.skeleton-line.long { width: 90%; }

.skeleton-chart {
  height: 300px;
  border-radius: 12px;
  margin-top: 12px;
}

.skeleton-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.skeleton-row:last-child { border-bottom: none; }

.skeleton-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
}

.skeleton-row-lines { flex: 1; }

.skeleton-row-lines .skeleton-line { margin-bottom: 6px; }
.skeleton-row-lines .skeleton-line:last-child { margin-bottom: 0; }

.skeleton-amount {
  width: 60px;
  height: 18px;
  border-radius: 4px;
  flex-shrink: 0;
}

/* Skeleton layout helpers */
.skeleton-stats-grid {
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.skeleton-charts-wrap {
  padding: 0 16px;
}

.skeleton-charts-wrap .skeleton-card {
  margin: 0 0 16px;
}

.skeleton-month-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 16px;
  background: rgba(255,255,255,.95);
}

.skeleton-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.skeleton-month-label {
  width: 100px;
  height: 20px;
  border-radius: 4px;
}

.skeleton-summary {
  padding: 20px 12px;
  background: rgba(255,255,255,.95);
  display: flex;
  justify-content: space-around;
  gap: 12px;
}

.skeleton-summary-item {
  text-align: center;
  flex: 1;
}

.skeleton-summary-label {
  width: 50%;
  height: 14px;
  margin: 0 auto 8px;
  border-radius: 4px;
}

.skeleton-summary-value {
  width: 70%;
  height: 18px;
  margin: 0 auto;
  border-radius: 4px;
}

.skeleton-form-wrap {
  padding: 16px;
}

.skeleton-type-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.skeleton-type-btn {
  flex: 1;
  height: 44px;
  border-radius: 8px;
}

.skeleton-category-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.skeleton-category-item {
  height: 44px;
  border-radius: 8px;
}

.skeleton-input {
  width: 100%;
  height: 48px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.skeleton-textarea {
  width: 100%;
  height: 80px;
  border-radius: 8px;
  margin-bottom: 12px;
}

/* Nav progress bar */
.nav-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 3px;
  background: linear-gradient(90deg, #667eea, #764ba2);
  z-index: 10000;
  pointer-events: none;
}

.nav-progress.active {
  width: 70%;
  transition: width 8s cubic-bezier(.1,.05,.1,1);
}

.nav-progress.done {
  width: 100%;
  opacity: 0;
  transition: width .2s ease, opacity .3s ease .2s;
}

.nav-bar a.nav-loading {
  opacity: .5;
  pointer-events: none;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #999;
}
