﻿:root {
  --bg: #f7f5ef;
  --ink: #1f2937;
  --muted: #6b7280;
  --card: rgba(255, 255, 255, 0.86);
  --line: #d2d6dc;
  --accent: #c2410c;
  --accent-soft: #fff4ec;
  --success: #1d4ed8;
  --danger: #b91c1c;
  --shadow: 0 10px 25px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 0% 0%, #ffe4c5 0%, transparent 42%),
    radial-gradient(circle at 100% 20%, #e7f0ff 0%, transparent 36%),
    linear-gradient(180deg, #f9f7f1 0%, #f3f4f6 100%);
  position: relative;
}

.bg-shape {
  position: fixed;
  z-index: 0;
  pointer-events: none;
  filter: blur(1px);
}

.bg-shape-a {
  width: 270px;
  height: 270px;
  right: -50px;
  top: 56px;
  border-radius: 30% 70% 60% 40%;
  background: linear-gradient(140deg, rgba(194, 65, 12, 0.2), rgba(255, 255, 255, 0.4));
}

.bg-shape-b {
  width: 240px;
  height: 240px;
  left: -40px;
  bottom: 90px;
  border-radius: 64% 36% 44% 56%;
  background: linear-gradient(130deg, rgba(29, 78, 216, 0.18), rgba(255, 255, 255, 0.45));
}

.page {
  width: min(1180px, calc(100vw - 28px));
  margin: 20px auto 30px;
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
}

.card {
  border: 1px solid rgba(255, 255, 255, 0.8);
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.hero {
  padding: 18px 20px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(22px, 3.2vw, 32px);
  letter-spacing: 0.4px;
}

.hero p {
  margin: 8px 0 0;
  color: #374151;
  line-height: 1.6;
}

.meta {
  margin-top: 12px;
  display: inline-block;
  font-size: 13px;
  color: #92400e;
  background: var(--accent-soft);
  border: 1px dashed #fed7aa;
  border-radius: 999px;
  padding: 5px 12px;
}

.section {
  padding: 16px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.section-head-card {
  padding: 16px;
  margin-bottom: 0;
}

.section-head h2 {
  margin: 0;
  font-size: 19px;
}

.form-mode-hint {
  font-size: 13px;
  color: #1e40af;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 4px 10px;
  font-weight: 600;
}

.record-count {
  font-size: 13px;
  color: var(--muted);
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
}

.history-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.history-filters {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.filter-item {
  display: grid;
  gap: 5px;
}

.filter-item span {
  font-size: 13px;
  color: #374151;
}

.history-filters select {
  min-width: 150px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

.history-filters select:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(147, 197, 253, 0.22);
}

button.clear-filters-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: #334155;
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 600;
}

button.clear-filters-btn:hover {
  transform: none;
  box-shadow: none;
  background: #f8fafc;
}

#exportBackupBtn,
#importBackupBtn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
}

#exportBackupBtn:hover,
#importBackupBtn:hover {
  transform: none;
  box-shadow: none;
  background: #f8fafc;
}

.entry-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
}

.entry-form label {
  display: grid;
  gap: 6px;
}

.entry-form span {
  font-size: 13px;
  color: #374151;
}

.entry-form input,
.entry-form textarea,
button {
  font: inherit;
}

.entry-form input,
.entry-form textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 11px;
  color: var(--ink);
  background: #fff;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.entry-form input:focus,
.entry-form textarea:focus {
  outline: none;
  border-color: #fdba74;
  box-shadow: 0 0 0 3px rgba(251, 146, 60, 0.18);
}

.entry-form .wide {
  grid-column: span 2;
}

.form-actions {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
}

.cancel-edit-btn {
  border: 1px solid #94a3b8;
  background: #fff;
  color: #334155;
}

.cancel-edit-btn:hover {
  transform: none;
  box-shadow: none;
  background: #f8fafc;
}

button {
  border: 1px solid #f97316;
  background: linear-gradient(140deg, #f97316, #ea580c);
  color: #fff;
  border-radius: 10px;
  padding: 10px 18px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.2px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(234, 88, 12, 0.25);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

thead {
  background: #f9fafb;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid #eef1f5;
  text-align: left;
  font-size: 13px;
  vertical-align: top;
}

th {
  color: #374151;
  white-space: nowrap;
}

td {
  color: #1f2937;
}

tbody tr:hover {
  background: #fff9f5;
}

.empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 26px 12px;
}

.row-actions-cell {
  white-space: nowrap;
}

.edit-btn {
  border: 1px solid #93c5fd;
  background: #fff;
  color: #1d4ed8;
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 600;
  margin-right: 6px;
}

.edit-btn:hover {
  box-shadow: none;
  transform: none;
  background: #dbeafe;
}

.delete-btn {
  border: 1px solid #ef4444;
  background: #fff;
  color: #b91c1c;
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 600;
}

.delete-btn:hover {
  box-shadow: none;
  transform: none;
  background: #fee2e2;
}

.charts {
  display: grid;
  gap: 14px;
}

.chart-card {
  padding: 14px 16px 16px;
}

.chart-card h3 {
  margin: 0;
  font-size: 16px;
}

.chart-card p {
  margin: 7px 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.chart-legend {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
}

.chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #334155;
  border: 1px solid #dbe3ef;
  background: #f8fafc;
  border-radius: 999px;
  padding: 3px 9px;
}

.chart-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  display: inline-block;
  flex-shrink: 0;
}

.chart-legend-empty {
  font-size: 12px;
  color: var(--muted);
}

canvas {
  width: 100%;
  height: 260px;
  display: block;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(251, 252, 255, 0.98), rgba(244, 247, 251, 0.98));
  border: 1px solid #e5e7eb;
}

@media (max-width: 1000px) {
  .entry-form {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }
}

@media (max-width: 760px) {
  .page {
    width: calc(100vw - 18px);
    margin-top: 10px;
  }

  .section,
  .hero,
  .chart-card,
  .section-head-card {
    padding: 12px;
  }

  .entry-form {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .entry-form .wide {
    grid-column: span 2;
  }

  th,
  td {
    font-size: 12px;
    padding: 8px;
  }
}

@media (max-width: 520px) {
  .entry-form {
    grid-template-columns: 1fr;
  }

  .entry-form .wide {
    grid-column: span 1;
  }

  .history-filters {
    align-items: stretch;
  }

  .history-filters select,
  .clear-filters-btn {
    width: 100%;
  }
}
