:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --surface: #ffffff;
  --ink: #17211c;
  --muted: #69746d;
  --line: #dfe5df;
  --primary: #126b57;
  --primary-dark: #0c4f40;
  --accent: #d57a2b;
  --danger: #b3261e;
  --shadow: 0 16px 40px rgba(23, 33, 28, 0.09);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.65rem, 8vw, 2.4rem);
  line-height: 1.1;
}

h2 {
  font-size: 1.1rem;
}

.today-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.86rem;
  box-shadow: 0 8px 20px rgba(23, 33, 28, 0.05);
}

.summary-band {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.date-row,
.result-panel,
.carry-panel,
.money-form,
.history-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.date-row {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 8px;
  align-items: end;
  padding: 12px;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbf8;
  color: var(--ink);
  font-size: 1.8rem;
  line-height: 1;
}

.result-panel {
  padding: 18px;
  background: linear-gradient(135deg, #103d34, #126b57);
  color: #ffffff;
}

.result-panel span,
.carry-panel span {
  display: block;
  font-size: 0.9rem;
  opacity: 0.85;
}

.result-panel strong {
  display: block;
  margin: 8px 0 4px;
  font-size: clamp(2.1rem, 12vw, 3.6rem);
  line-height: 1;
}

.result-panel small {
  color: rgba(255, 255, 255, 0.82);
}

.carry-panel {
  display: grid;
  gap: 6px;
  padding: 14px;
}

.carry-panel strong {
  display: block;
  margin-top: 4px;
  font-size: 1.45rem;
  color: var(--accent);
}

.carry-panel small,
label small,
.section-heading span {
  color: var(--muted);
  font-size: 0.82rem;
}

.money-form,
.history-section {
  display: grid;
  gap: 14px;
  padding: 14px;
  margin-bottom: 14px;
}

.form-section {
  display: grid;
  gap: 12px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 750;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--ink);
  padding: 12px;
  min-height: 46px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(18, 107, 87, 0.15);
}

.inline-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px;
  gap: 8px;
}

.add-collection {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 108px 72px;
  gap: 8px;
  align-items: end;
}

.primary-button,
.secondary-button,
.text-button {
  border: 0;
  border-radius: 8px;
  min-height: 48px;
  padding: 0 16px;
  font-weight: 850;
}

.primary-button {
  background: var(--primary);
  color: #ffffff;
}

.primary-button:active {
  background: var(--primary-dark);
}

.secondary-button {
  background: #eef2ee;
  color: var(--ink);
}

.compact {
  min-height: 46px;
  padding: 0 10px;
}

.text-button {
  min-height: auto;
  padding: 4px 0;
  background: transparent;
  color: var(--primary);
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.collection-list,
.history-list {
  display: grid;
  gap: 8px;
}

.collection-item,
.history-item {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfa;
  color: var(--ink);
  text-align: left;
}

.collection-item {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.collection-item strong,
.history-item strong {
  font-size: 1.05rem;
}

.collection-meta,
.history-meta {
  color: var(--muted);
  font-size: 0.84rem;
}

.delete-button {
  border: 0;
  border-radius: 8px;
  min-width: 42px;
  height: 38px;
  background: #f8e8e6;
  color: var(--danger);
  font-weight: 900;
}

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

@media (max-width: 460px) {
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .topbar {
    display: grid;
  }

  .today-pill {
    width: max-content;
  }

  .add-collection {
    grid-template-columns: 1fr 106px;
  }

  .add-collection .primary-button {
    grid-column: 1 / -1;
  }
}
