:root {
  color-scheme: light;
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  background: #f4f7f4;
  color: #1f2a24;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-header,
main {
  width: min(100% - 24px, 980px);
  margin-inline: auto;
}

.app-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 0 14px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.35rem, 4vw, 2rem);
}

h2 {
  font-size: 1.15rem;
}

h3 {
  margin: 18px 0 8px;
  color: #435449;
  font-size: 1rem;
}

.eyebrow {
  margin-bottom: 4px;
  color: #64816e;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.month-picker,
.adjustment-form label,
.item-form label {
  display: grid;
  gap: 4px;
  color: #52645a;
  font-size: 0.8rem;
  font-weight: 700;
}

input {
  min-height: 42px;
  border: 1px solid #c7d3cc;
  border-radius: 9px;
  background: white;
  padding: 8px 10px;
}

select {
  min-height: 42px;
  border: 1px solid #c7d3cc;
  border-radius: 9px;
  background: white;
  padding: 8px 10px;
}

main {
  display: grid;
  gap: 14px;
  padding-bottom: 40px;
}

.panel,
.summary-card {
  border: 1px solid #d9e3dc;
  border-radius: 14px;
  background: white;
  box-shadow: 0 5px 18px rgb(45 78 58 / 7%);
}

.panel {
  padding: 16px;
}

.compact {
  padding-bottom: 12px;
}

.toolbar,
.section-heading,
.backup-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.child-tabs {
  display: flex;
  gap: 8px;
}

.button,
.child-tab {
  min-height: 42px;
  border: 1px solid #b7c8bd;
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 700;
}

.button.primary,
.child-tab.active {
  border-color: #237345;
  background: #237345;
  color: white;
}

.button.secondary,
.child-tab {
  background: #f8fbf9;
  color: #2c6041;
}

.hint {
  margin-top: 10px;
  color: #65766c;
  font-size: 0.85rem;
  line-height: 1.6;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.summary-card {
  display: grid;
  gap: 4px;
  padding: 14px;
}

.summary-card span {
  color: #617168;
  font-size: 0.8rem;
}

.summary-card strong {
  font-size: 1.2rem;
}

.summary-card.positive strong {
  color: #237345;
}

.summary-card.negative strong {
  color: #b43b3b;
}

.summary-card.total {
  border-color: #6c9b7e;
  background: #edf8f0;
}

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

.item-card {
  display: grid;
  gap: 8px;
  border: 1px solid #dde6e0;
  border-radius: 11px;
  padding: 8px;
}

.item-add {
  display: grid;
  gap: 6px;
  min-height: 64px;
  border: 0;
  border-radius: 8px;
  background: #edf8f0;
  padding: 10px;
  text-align: left;
}

.item-name {
  font-weight: 700;
  line-height: 1.35;
}

.item-price {
  color: #237345;
  font-size: 0.82rem;
  font-weight: 700;
}

.item-card.negative .item-add {
  background: #fff2f2;
}

.item-card.negative .item-price {
  color: #b43b3b;
}

.counter {
  display: grid;
  grid-template-columns: 34px 1fr 34px minmax(58px, auto);
  align-items: center;
  gap: 6px;
}

.counter button {
  width: 34px;
  height: 34px;
  border: 1px solid #c8d5cd;
  border-radius: 8px;
  background: white;
  color: #365243;
  font-weight: 800;
}

.count-value {
  text-align: center;
  font-size: 0.88rem;
}

.item-subtotal {
  text-align: right;
  font-size: 0.9rem;
}

.item-delete {
  justify-self: end;
  border: 0;
  background: transparent;
  color: #b43b3b;
  font-size: 0.78rem;
  font-weight: 700;
}

.adjustment-form {
  display: grid;
  grid-template-columns: minmax(120px, 0.5fr) minmax(160px, 1fr) auto;
  gap: 10px;
  margin-top: 12px;
}

.item-form {
  display: grid;
  grid-template-columns: minmax(130px, 0.5fr) minmax(180px, 1fr) minmax(120px, 0.5fr) auto;
  gap: 10px;
  margin-top: 12px;
}

.adjustment-list,
.history-list,
.activity-list {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.adjustment-row,
.history-row,
.activity-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid #e6ede8;
  padding-top: 8px;
  font-size: 0.9rem;
}

.activity-detail {
  display: grid;
  gap: 2px;
}

.activity-date {
  color: #65766c;
  font-size: 0.78rem;
}

.activity-amount {
  white-space: nowrap;
}

.inline-delete {
  border: 0;
  background: transparent;
  color: #b43b3b;
  font-weight: 700;
}

.file-button input {
  display: none;
}

@media (max-width: 700px) {
  .app-header {
    align-items: start;
    flex-direction: column;
  }

  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

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

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