:root {
  color-scheme: light;
  --ink: #22332f;
  --muted: #6d7d75;
  --line: #dfe8e2;
  --paper: #fbfaf6;
  --panel: #ffffff;
  --green: #285947;
  --green-soft: #e8f0ea;
  --gold: #b8893c;
  --rose: #b56f64;
  --shadow: 0 18px 50px rgba(34, 51, 47, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(135deg, #f7f3ea 0%, #eef5ef 52%, #fbfaf6 100%);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 32px 24px;
  background: rgba(255, 255, 255, 0.72);
  border-right: 1px solid rgba(223, 232, 226, 0.9);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  color: #fff;
  background: var(--green);
  box-shadow: 0 8px 20px rgba(40, 89, 71, 0.18);
  font-size: 24px;
  font-weight: 700;
}

.brand h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.brand p,
.eyebrow {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.nav-tabs {
  display: grid;
  gap: 10px;
}

.nav-tab {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.nav-tab.active,
.nav-tab:hover {
  color: var(--green);
  background: var(--green-soft);
  border-color: #d4e4d7;
}

.side-note {
  margin-top: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.side-note span {
  display: block;
  color: var(--gold);
  font-size: 13px;
  margin-bottom: 8px;
}

.side-note strong {
  display: block;
  line-height: 1.6;
  font-size: 16px;
}

.side-note small {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-size: 11px;
}

.content {
  padding: 34px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.page-head.compact {
  align-items: center;
}

.page-head h2 {
  margin: 4px 0 0;
  font-size: 26px;
}

.title-input {
  width: min(760px, 100%);
  border: 0;
  border-bottom: 1px solid transparent;
  color: var(--ink);
  background: transparent;
  font-size: 28px;
  font-weight: 700;
  outline: none;
  line-height: 1.25;
}

.title-input:focus {
  border-bottom-color: var(--gold);
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
}

input:focus {
  outline: 2px solid rgba(184, 137, 60, 0.22);
  border-color: var(--gold);
}

.date-field {
  width: 190px;
}

.archive-button {
  border: 0;
  border-radius: 8px;
  padding: 12px 18px;
  color: #fff;
  background: var(--green);
  box-shadow: 0 10px 24px rgba(40, 89, 71, 0.18);
}

.archive-button:hover {
  background: #1f4738;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric,
.panel {
  border: 1px solid rgba(223, 232, 226, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.metric {
  padding: 20px;
}

.metric span,
.total-panel span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.metric strong {
  font-size: 26px;
}

.metric.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--green), #3b725d);
}

.metric.primary span {
  color: rgba(255, 255, 255, 0.78);
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
  gap: 18px;
}

.panel {
  padding: 20px;
  margin-bottom: 18px;
}

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

.panel-title h2 {
  margin: 0;
  font-size: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.summary-list {
  display: grid;
  gap: 12px;
}

.summary-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.summary-list div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.summary-list span {
  color: var(--muted);
}

.activity-list {
  display: grid;
  gap: 12px;
}

.activity-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 10px;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.activity-card.active {
  border-color: #b8cfbd;
  background: var(--green-soft);
}

.activity-main {
  display: grid;
  gap: 6px;
  border: 0;
  padding: 14px 16px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.activity-main span {
  font-size: 17px;
  font-weight: 700;
}

.activity-main small {
  color: var(--muted);
  font-size: 12px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

td input {
  min-width: 96px;
}

td input[data-annual] {
  min-width: 120px;
}

.amount {
  font-weight: 700;
}

.expense-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.expense-card {
  margin-bottom: 0;
}

.expense-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.expense-total span {
  color: var(--muted);
}

.text-button,
.ghost-button,
.delete-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--green);
  background: #fff;
}

.text-button,
.ghost-button {
  padding: 9px 12px;
}

.compact-button {
  padding: 6px 10px;
}

.action-cell {
  display: flex;
  gap: 8px;
  align-items: center;
}

.text-button:hover,
.ghost-button:hover {
  border-color: var(--green);
  background: var(--green-soft);
}

.delete-button {
  width: 32px;
  height: 32px;
  color: var(--rose);
}

.delete-button:hover {
  border-color: var(--rose);
  background: #fbefed;
}

.total-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.total-panel strong {
  font-size: 24px;
}

.total-panel .highlight {
  padding-left: 18px;
  border-left: 3px solid var(--gold);
}

.yearly {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    padding: 22px;
  }

  .nav-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav-tab {
    text-align: center;
  }

  .side-note {
    display: none;
  }

  .metrics-grid,
  .two-column,
  .expense-grid,
  .total-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .content {
    padding: 16px;
  }

  .page-head {
    align-items: stretch;
    flex-direction: column;
  }

  .title-input {
    font-size: 21px;
    min-height: 44px;
  }

  .date-field {
    width: 100%;
  }

  .archive-button {
    width: 100%;
  }

  .form-grid,
  .nav-tabs {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 14px;
  }

  .metric {
    padding: 16px;
  }

  .metric strong {
    font-size: 22px;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  thead {
    display: none;
  }

  tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
    background: #fff;
  }

  td {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    border-bottom: 0;
    padding: 7px 0;
    white-space: normal;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
  }

  td input {
    min-width: 0;
  }

  td[data-label="操作"] {
    grid-template-columns: 1fr;
  }

  td[data-label="操作"]::before {
    display: none;
  }

  .delete-button {
    width: 100%;
  }

  .total-panel .highlight {
    padding-left: 0;
    padding-top: 14px;
    border-left: 0;
    border-top: 3px solid var(--gold);
  }
}
