:root {
  --bg: #f6f2ea;
  --ink: #13211d;
  --muted: #66716d;
  --panel: #fffdfa;
  --line: #e7dfd3;
  --brand: #0e4f43;
  --brand-soft: #dceee8;
  --income: #177245;
  --expense: #b6402b;
  --shadow: 0 18px 44px rgba(41, 35, 24, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(14, 79, 67, 0.12), transparent 280px),
    var(--bg);
  font-family: Inter, "Avenir Next", "PingFang SC", "Hiragino Sans GB", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1080px, calc(100vw - 32px));
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 0 max(28px, env(safe-area-inset-bottom));
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 16px;
  align-items: stretch;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.78);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 2.6rem;
  line-height: 1;
}

h2 {
  font-size: 1.08rem;
}

.hero-text {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.7;
}

.month-card,
.summary-item,
.entry-form,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.month-card {
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 20px;
  color: white;
  background: var(--brand);
  border-color: transparent;
}

.month-card span,
.month-card small {
  color: rgba(255, 255, 255, 0.72);
}

.month-card strong {
  font-size: 1.9rem;
  line-height: 1.1;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.summary-item {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.summary-item span,
.field span,
.record span,
.category-row span {
  color: var(--muted);
}

.summary-item strong {
  font-size: 1.35rem;
}

.summary-item.income strong,
.income {
  color: var(--income);
}

.summary-item.expense strong,
.expense {
  color: var(--expense);
}

.workspace {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.insight-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.8fr);
  gap: 16px;
  margin-top: 16px;
}

.trend-panel {
  grid-column: span 2;
}

.entry-form,
.panel {
  padding: 18px;
  box-shadow: 0 10px 24px rgba(41, 35, 24, 0.06);
}

.form-header,
.panel-header,
.record,
.record-main,
.record-side,
.category-line,
.actions,
.bill-row {
  display: flex;
  align-items: center;
}

.form-header,
.panel-header,
.record,
.category-line,
.bill-row {
  justify-content: space-between;
  gap: 14px;
}

.type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border-radius: 8px;
  background: #f0ece4;
}

.type-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.type-toggle label {
  min-width: 64px;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--muted);
  text-align: center;
  user-select: none;
}

.type-toggle input:checked + label {
  color: white;
  background: var(--brand);
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.field input,
.field select,
#month-filter,
.inline-form input,
.search-input {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
}

.primary-button {
  width: 100%;
  height: 48px;
  margin-top: 18px;
  border: 0;
  border-radius: 8px;
  color: white;
  background: var(--brand);
  font-weight: 800;
}

.primary-button:active,
.icon-button:active,
.record button:active {
  transform: translateY(1px);
}

.category-list,
.record-list,
.budget-list,
.bill-list,
.trend-chart {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.category-row,
.budget-row,
.bill-row {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #f0ece4;
}

.meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

.meter.danger span {
  background: var(--expense);
}

.budget-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 100px;
  gap: 10px;
  align-items: center;
}

.budget-control input {
  height: 36px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 70px 68px;
  gap: 8px;
  margin-top: 16px;
}

.inline-form input {
  height: 40px;
}

.inline-form button {
  border: 0;
  border-radius: 8px;
  color: white;
  background: var(--brand);
  font-weight: 800;
}

.bill-row {
  display: flex;
}

.bill-row > div:first-child {
  display: grid;
  gap: 4px;
}

.trend-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 116px;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.trend-row:last-child {
  border-bottom: 0;
}

.trend-row > span {
  color: var(--muted);
}

.trend-row > strong {
  justify-self: end;
}

.trend-bars {
  display: grid;
  gap: 5px;
}

.trend-bars i {
  display: block;
  height: 8px;
  min-width: 3px;
  border-radius: 999px;
}

.income-bar {
  background: var(--income);
}

.expense-bar {
  background: var(--expense);
}

.records-panel {
  margin-top: 16px;
}

.actions {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--brand);
  background: #fff;
  font-size: 1.1rem;
  font-weight: 900;
}

.icon-button span {
  font-size: 0.75rem;
}

.search-input {
  width: 190px;
  height: 42px;
}

.file-button input {
  display: none;
}

.record {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.record-main,
.record-side {
  gap: 10px;
}

.record-main > div,
.record-side {
  display: grid;
  gap: 4px;
}

.record-side {
  justify-items: end;
}

.badge {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: white;
  font-weight: 900;
}

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

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

.record button {
  border: 0;
  padding: 0;
  color: var(--muted);
  background: transparent;
  font-size: 0.82rem;
}

.bill-row button {
  border: 0;
  padding: 0;
  color: var(--muted);
  background: transparent;
  font-size: 0.82rem;
}

.empty-state {
  display: grid;
  gap: 6px;
  padding: 26px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
}

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

  .hero,
  .workspace,
  .insight-grid {
    grid-template-columns: 1fr;
  }

  .trend-panel {
    grid-column: auto;
  }

  .hero {
    padding: 18px;
  }

  h1 {
    font-size: 2.2rem;
  }
}

@media (max-width: 560px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-header,
  .record,
  .bill-row {
    align-items: stretch;
    flex-direction: column;
  }

  .actions {
    justify-content: stretch;
  }

  .search-input {
    width: 100%;
  }

  .inline-form {
    grid-template-columns: 1fr;
  }

  .trend-row {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .trend-row > strong {
    grid-column: 2;
    justify-self: start;
  }

  .record-side {
    grid-template-columns: 1fr auto;
    justify-items: start;
    width: 100%;
  }
}
