:root {
  color-scheme: light;
  --ink: #19212a;
  --muted: #66717e;
  --line: #d9e0e6;
  --paper: #ffffff;
  --bg: #f4f6f1;
  --green: #18805c;
  --red: #c84b45;
  --blue: #2f6fb4;
  --amber: #c68521;
  --shadow: 0 18px 45px rgba(25, 33, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(47, 111, 180, 0.08) 0 1px, transparent 1px 100%),
    linear-gradient(0deg, rgba(24, 128, 92, 0.08) 0 1px, transparent 1px 100%),
    var(--bg);
  background-size: 32px 32px;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.home-page {
  display: grid;
  place-items: center;
}

.home-shell {
  width: min(760px, calc(100% - 32px));
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 0;
}

.hello-panel {
  width: 100%;
}

.hello-panel h1 {
  font-size: clamp(4rem, 16vw, 8rem);
  margin-bottom: 28px;
}

.home-actions {
  display: grid;
  grid-template-columns: minmax(0, 320px);
  gap: 12px;
}

.home-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  padding: 0 22px;
  font-size: 1.25rem;
  font-weight: 800;
}

.home-card::after {
  content: "›";
  font-size: 2rem;
  line-height: 1;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 0 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 0.85rem;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4.2rem);
  line-height: 1;
}

h2 {
  font-size: 1.05rem;
}

.month-switcher,
.filters,
.record-side,
.section-heading {
  display: flex;
  align-items: center;
}

.month-switcher {
  gap: 8px;
}

.icon-button,
.ghost-button,
.primary-button,
.delete-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
}

.icon-button {
  width: 42px;
  font-size: 1.7rem;
  line-height: 1;
}

.ghost-button {
  padding: 0 14px;
}

.ghost-link {
  display: inline-grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 0 14px;
  color: var(--ink);
}

.ghost-button.danger {
  color: var(--red);
}

.primary-button {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 16px;
}

.summary-band,
.entry-panel,
.insights-panel,
.records-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.summary-band {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  overflow: hidden;
  background: var(--line);
}

.metric {
  min-height: 104px;
  padding: 20px;
  background: var(--paper);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.metric.income strong {
  color: var(--green);
}

.metric.expense strong {
  color: var(--red);
}

.entry-panel,
.insights-panel,
.records-panel {
  padding: 18px;
}

.entry-panel {
  grid-row: span 2;
}

.section-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-heading span {
  color: var(--muted);
  font-size: 0.9rem;
}

.entry-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.entry-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
}

.wide,
.type-toggle {
  grid-column: 1 / -1;
}

.type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.type-toggle label {
  color: var(--ink);
}

.type-toggle input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.type-toggle span {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 700;
}

.type-toggle input:checked + span {
  border-color: var(--blue);
  background: #e8f1fb;
  color: #164d86;
}

.category-bars {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(64px, 110px) 1fr minmax(72px, auto);
  gap: 10px;
  align-items: center;
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: #e6ebee;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--amber);
}

.bar-row strong {
  text-align: right;
  font-size: 0.9rem;
}

.records-panel {
  min-height: 360px;
}

.filters {
  gap: 8px;
}

.filters select {
  min-width: 112px;
}

.record-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.record-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.record-main {
  min-width: 0;
}

.record-category {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef4ec;
  color: #246247;
  font-size: 0.78rem;
  font-weight: 800;
}

.record-note {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.record-date {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.record-side {
  flex-shrink: 0;
  gap: 8px;
}

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

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

.delete-button {
  width: 36px;
  min-height: 36px;
  color: var(--muted);
  font-size: 1.2rem;
}

.empty-state {
  display: none;
  min-height: 220px;
  place-items: center;
  text-align: center;
  color: var(--muted);
}

.empty-state strong,
.empty-state span {
  display: block;
}

.empty-state strong {
  color: var(--ink);
  margin-bottom: 6px;
}

.empty-state.visible {
  display: grid;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 680px);
    padding-top: 14px;
  }

  .topbar,
  .layout,
  .summary-band {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
    align-items: stretch;
  }

  .month-switcher {
    justify-content: stretch;
  }

  .month-switcher input {
    flex: 1;
  }

  .entry-panel {
    grid-row: auto;
  }
}

@media (max-width: 520px) {
  .entry-form,
  .type-toggle {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr minmax(72px, auto);
  }

  .bar-track {
    grid-column: 1 / -1;
    order: 3;
  }

  .record-item {
    align-items: flex-start;
  }
}
