/* 基础样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: #f5f7fa;
  color: #333;
  line-height: 1.6;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* 头部样式 */
.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 24px;
  color: white;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

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

.header h1 {
  font-size: 22px;
  font-weight: 600;
}

.book-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.2);
  padding: 6px 12px;
  border-radius: 8px;
}

.book-selector select {
  background: rgba(255, 255, 255, 0.9);
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 14px;
  min-width: 120px;
}

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

.month-selector {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.2);
  padding: 8px 16px;
  border-radius: 8px;
}

.month-selector span {
  font-size: 16px;
  font-weight: 500;
  min-width: 90px;
  text-align: center;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.3);
  border: none;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.5);
}

.balance-display {
  display: flex;
  align-items: center;
  gap: 16px;
}

.balance-card {
  display: flex;
  flex-direction: column;
}

.balance-label {
  font-size: 12px;
  opacity: 0.9;
}

.balance-amount {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 1px;
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.2);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-indicator::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4caf50;
}

.status-indicator.syncing::before {
  background: #ff9800;
  animation: pulse 1s infinite;
}

.status-indicator.error::before {
  background: #f44336;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* 按钮样式 */
.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: white;
  color: #667eea;
  border: 2px solid #667eea;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: #667eea;
  color: white;
}

.btn-small {
  background: rgba(255, 255, 255, 0.9);
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  color: #667eea;
  font-weight: 600;
  transition: background 0.2s;
}

.btn-small:hover {
  background: white;
}

.btn-share {
  background: #07c160;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-share:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(7, 193, 96, 0.4);
}

.btn-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #666;
  transition: color 0.2s;
}

.btn-close:hover {
  color: #333;
}

/* 表单区域 */
.form-section {
  background: white;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.form-section h2 {
  font-size: 18px;
  margin-bottom: 16px;
  color: #333;
  border-bottom: 2px solid #667eea;
  padding-bottom: 8px;
}

.record-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.form-group {
  flex: 1;
  min-width: 120px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group.flex-grow {
  flex: 2;
}

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: #555;
}

.form-group input,
.form-group select {
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group input[readonly] {
  background: #f5f5f5;
  cursor: default;
}

.select-with-btn {
  display: flex;
  gap: 6px;
}

.select-with-btn select {
  flex: 1;
}

.type-selector {
  display: flex;
  gap: 8px;
}

.type-radio {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.type-radio input[type="radio"] {
  display: none;
}

.income-label,
.expense-label {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}

.income-label {
  background: #e8f5e9;
  color: #2e7d32;
}

.expense-label {
  background: #ffebee;
  color: #c62828;
}

.type-radio input[type="radio"]:checked + .income-label {
  background: #2e7d32;
  color: white;
}

.type-radio input[type="radio"]:checked + .expense-label {
  background: #c62828;
  color: white;
}

/* 表格区域 */
.table-section {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

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

.table-header h2 {
  font-size: 18px;
  color: #333;
  border-bottom: 2px solid #667eea;
  padding-bottom: 8px;
}

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

.table-wrapper {
  overflow-x: auto;
}

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

th {
  background: #f8f9fa;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: #555;
  border-bottom: 2px solid #dee2e6;
  white-space: nowrap;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid #eee;
}

/* 摘要列截断 */
td.summary-cell {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
  position: relative;
}

td.summary-cell:hover {
  white-space: normal;
  overflow: visible;
  position: relative;
  z-index: 10;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  border-radius: 4px;
  max-width: 300px;
}

tr:hover {
  background: #f8f9fa;
}

.summary-row {
  background: #f8f9fa !important;
  font-weight: 600;
}

.summary-label {
  text-align: right;
  color: #333;
}

.summary-value {
  color: #667eea;
  font-size: 15px;
}

/* 类型标签 */
.type-income {
  background: #e8f5e9;
  color: #2e7d32;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.type-expense {
  background: #ffebee;
  color: #c62828;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.income-amount {
  color: #2e7d32;
  font-weight: 500;
}

.expense-amount {
  color: #c62828;
  font-weight: 500;
}

/* 操作按钮 */
.action-buttons {
  display: flex;
  gap: 4px;
}

.btn-edit {
  background: #e3f2fd;
  color: #1976d2;
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.2s;
}

.btn-edit:hover {
  background: #bbdefb;
}

.btn-delete {
  background: #ffebee;
  color: #c62828;
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.2s;
}

.btn-delete:hover {
  background: #ffcdd2;
}

/* 模态框 */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

#screenshotModal .modal-content {
  max-width: 95vw;
  overflow-x: auto;
}

.modal-small {
  max-width: 400px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
}

.modal-header h3 {
  font-size: 16px;
  color: #333;
}

.modal-body {
  padding: 20px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding: 16px 20px;
  border-top: 1px solid #eee;
}

/* 截图预览 */
.screenshot-container {
  padding: 20px;
  display: flex;
  justify-content: center;
  background: #f5f7fa;
  overflow-x: auto;
}

.screenshot-preview {
  width: 480px;
  min-height: 300px;
  background: white;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  font-size: 12px;
}

.screenshot-header {
  text-align: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #667eea;
}

.screenshot-header h3 {
  font-size: 16px;
  color: #333;
  margin-bottom: 6px;
}

.screenshot-header p {
  font-size: 11px;
  color: #666;
}

.screenshot-preview table {
  font-size: 11px;
  width: 100%;
  table-layout: fixed;
}

.screenshot-preview th {
  padding: 6px 8px;
  font-size: 10px;
  white-space: nowrap;
}

.screenshot-preview td {
  padding: 6px 8px;
  font-size: 10px;
  white-space: nowrap;
}

/* 滑块设置 */
.slider-setting {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slider-setting label {
  font-size: 14px;
  font-weight: 500;
  color: #333;
}

.slider-setting input[type="range"] {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: #e0e0e0;
  border-radius: 3px;
  outline: none;
}

.slider-setting input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #667eea;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
}

.slider-setting small {
  font-size: 12px;
  color: #888;
}

.slider-preview {
  margin-top: 4px;
}

/* 截图各列宽度 */
.screenshot-preview th:nth-child(1),
.screenshot-preview td:nth-child(1) { width: 75px; } /* 日期 */
.screenshot-preview th:nth-child(2),
.screenshot-preview td:nth-child(2) { width: 55px; } /* 账户 */
.screenshot-preview th:nth-child(3),
.screenshot-preview td:nth-child(3) { width: 50px; } /* 客户 */
.screenshot-preview th:nth-child(4),
.screenshot-preview td:nth-child(4) { /* 摘要 - 占剩余空间 */
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
}
.screenshot-preview th:nth-child(5),
.screenshot-preview td:nth-child(5) { width: 36px; } /* 类型 */
.screenshot-preview th:nth-child(6),
.screenshot-preview td:nth-child(6) { width: 75px; } /* 金额 */

.screenshot-footer {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 2px solid #667eea;
  text-align: right;
}

.screenshot-footer p {
  font-size: 13px;
  font-weight: 600;
  color: #333;
}

/* 设置区域 */
.settings-section {
  margin-bottom: 20px;
}

.settings-section h4 {
  font-size: 14px;
  color: #333;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eee;
}

.item-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #f8f9fa;
  border-radius: 6px;
}

.item-info {
  display: flex;
  gap: 12px;
  font-size: 13px;
}

.item-actions {
  display: flex;
  gap: 6px;
}

/* 危险区域 */
.danger-zone {
  border: 1px solid #ffcdd2;
  border-radius: 8px;
  padding: 12px;
  background: #fff5f5;
}

.danger-zone h4 {
  color: #c62828;
  border-bottom-color: #ffcdd2;
}

.btn-danger {
  background: #c62828;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s;
}

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

.danger-hint {
  font-size: 12px;
  color: #888;
  margin-top: 8px;
}

/* 响应式 */
@media (max-width: 768px) {
  .container {
    padding: 12px;
  }

  .header {
    padding: 16px;
  }

  .header-top {
    flex-direction: column;
    gap: 12px;
  }

  .header-bottom {
    flex-direction: column;
    align-items: stretch;
  }

  .balance-display {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

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

  .form-group {
    min-width: 100%;
  }

  .table-header {
    flex-direction: column;
    align-items: stretch;
  }

  .table-actions {
    justify-content: stretch;
  }

  .table-actions .btn-secondary,
  .table-actions .btn-primary {
    flex: 1;
  }
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 30px;
  color: #999;
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 6px;
}

.empty-state small {
  font-size: 12px;
}

/* 复选框样式 */
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

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

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #555;
}
