:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --income: #059669;
  --income-bg: #ecfdf5;
  --expense: #e11d48;
  --expense-bg: #fff1f2;
  --radius: 14px;
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.app-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.25);
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.month-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.month-picker input {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  width: 100%;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--surface-subtle);
}

.file-btn {
  display: inline-flex;
  align-items: center;
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}

.btn-link.danger {
  color: var(--expense);
}

.hidden {
  display: none !important;
}

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

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.summary-label {
  font-size: 13px;
  color: var(--text-muted);
}

.summary-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.summary-card.income .summary-value {
  color: var(--income);
}

.summary-card.expense .summary-value {
  color: var(--expense);
}

.summary-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.main-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

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

.panel-header h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.type-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 14px;
}

.type-btn {
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.type-btn.active[data-type="expense"] {
  background: var(--expense-bg);
  color: var(--expense);
  font-weight: 600;
}

.type-btn.active[data-type="income"] {
  background: var(--income-bg);
  color: var(--income);
  font-weight: 600;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

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

.form-row label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.form-row input,
.form-row select,
.filters select,
.filters input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s ease;
}

.form-row input:focus,
.form-row select:focus,
.filters select:focus,
.filters input:focus {
  border-color: var(--primary);
}

.media-upload-box {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  padding: 12px;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface-subtle);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.media-upload-box:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.media-preview-box {
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: var(--surface-subtle);
}

.media-preview-stage img,
.media-preview-stage video {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  background: #000;
}

.media-preview-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 12px;
}

.media-file-name {
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.breakdown-section {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

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

.breakdown-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.breakdown-header span {
  font-size: 13px;
  color: var(--text-muted);
}

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

.breakdown-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.breakdown-item-top {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.breakdown-bar-track {
  height: 7px;
  border-radius: 999px;
  background: var(--surface-subtle);
  overflow: hidden;
}

.breakdown-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #fb7185, #e11d48);
}

.list-header {
  flex-wrap: wrap;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
  justify-content: flex-end;
}

.filters select {
  width: auto;
  min-width: 112px;
  font-size: 13px;
  padding: 7px 10px;
}

.filters input {
  width: 180px;
  font-size: 13px;
  padding: 7px 10px;
}

.records-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 260px;
}

.record-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-subtle);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.record-item:hover {
  border-color: #cbd5e1;
  background: #fff;
}

.record-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.record-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.record-badge.expense {
  background: var(--expense-bg);
  color: var(--expense);
}

.record-badge.income {
  background: var(--income-bg);
  color: var(--income);
}

.record-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.record-note {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.record-date {
  font-size: 12px;
  color: var(--text-muted);
}

.record-thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
  background: #0f172a;
}

.record-video-chip {
  padding: 4px 9px;
  border-radius: 8px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: var(--primary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.record-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.record-amount {
  font-size: 15px;
  font-weight: 700;
}

.record-amount.expense {
  color: var(--expense);
}

.record-amount.income {
  color: var(--income);
}

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

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
}

.icon-btn:hover {
  color: var(--text);
  border-color: #94a3b8;
}

.icon-btn.delete:hover {
  color: var(--expense);
  border-color: #fda4af;
}

.list-footer {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
}

.empty-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 28px 12px;
  margin: 0;
}

.media-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
}

.media-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(2px);
}

.media-modal-content {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  max-height: 90vh;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.35);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.media-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.media-modal-title {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-modal-body {
  display: grid;
  place-items: center;
  overflow: auto;
  background: #0f172a;
  border-radius: 10px;
  padding: 8px;
}

.media-modal-body img,
.media-modal-body video {
  max-width: 100%;
  max-height: 72vh;
  border-radius: 6px;
}

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

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

  .filters {
    justify-content: flex-start;
  }

  .filters input {
    width: 100%;
  }
}