:root {
  color-scheme: light;
  --bg: #f6f4ee;
  --ink: #263238;
  --muted: #66706c;
  --panel: #ffffff;
  --line: #d9dfd7;
  --green: #34785d;
  --green-dark: #225c45;
  --gold: #f2c14e;
  --blue: #7fb3d5;
  --red: #c75d4a;
  --shadow: 0 18px 50px rgba(46, 55, 46, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(127, 179, 213, 0.25), transparent 32rem),
    linear-gradient(135deg, #f6f4ee 0%, #ecf3eb 100%);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.balance-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
  padding: 28px;
  background: var(--green-dark);
  color: #fffaf0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.eyebrow,
.section-label,
.hint,
.form-message {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.balance-hero .eyebrow {
  color: rgba(255, 250, 240, 0.78);
}

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

h1 {
  margin-top: 6px;
  font-size: clamp(2rem, 7vw, 4.4rem);
}

h2 {
  font-size: 1.25rem;
}

h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  letter-spacing: 0;
}

.balance-card {
  min-width: 210px;
  padding: 18px;
  background: rgba(255, 250, 240, 0.12);
  border: 1px solid rgba(255, 250, 240, 0.26);
  border-radius: 8px;
}

.balance-label,
.balance-card strong {
  display: block;
}

.balance-label {
  color: rgba(255, 250, 240, 0.78);
}

.balance-card strong {
  margin-top: 8px;
  font-size: clamp(1.8rem, 5vw, 3rem);
}

.goal-section,
.visual-section,
.log-section,
.money-form {
  margin-top: 18px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.goal-button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  text-align: left;
}

.goal-button strong {
  display: block;
  margin-top: 5px;
  font-size: clamp(1.2rem, 4vw, 1.8rem);
}

#goalSummary {
  color: var(--green-dark);
  font-weight: 700;
  white-space: nowrap;
}

.progress-track {
  height: 22px;
  margin-top: 18px;
  overflow: hidden;
  background: #e6ece3;
  border-radius: 999px;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--gold));
  border-radius: inherit;
  transition: width 240ms ease;
}

.hint,
.empty-list,
.dialog-message {
  margin-top: 10px;
}

.empty-list,
.dialog-message {
  color: var(--muted);
}

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

.chart-block-wide {
  grid-column: 1 / -1;
}

.chart-box {
  min-height: 150px;
  color: var(--ink);
}

.chart-box svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

#pieChart svg {
  width: min(100%, 180px);
  margin: 0 auto;
}

#barChart svg {
  width: min(100%, 360px);
  margin: 0 auto;
}

.chart-empty {
  display: grid;
  min-height: 120px;
  place-items: center;
  padding: 18px;
  color: var(--muted);
  background: #fbfcf9;
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
}

.chart-axis,
.chart-grid-line {
  stroke: var(--line);
}

.chart-label,
.chart-value {
  fill: var(--muted);
  font-size: 12px;
}

.chart-value {
  fill: var(--ink);
  font-weight: 700;
}

.line-path {
  fill: none;
  stroke: var(--green-dark);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line-dot {
  fill: var(--gold);
  stroke: var(--green-dark);
  stroke-width: 2;
}

.bar-track {
  fill: #e6ece3;
}

.pie-legend {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
}

.legend-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border-radius: 3px;
}

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

.status-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-pills span {
  padding: 8px 10px;
  background: #eef6f1;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--green-dark);
}

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

.charge-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  background: #fbfcf9;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.charge-item input {
  width: 20px;
  height: 20px;
  accent-color: var(--green);
}

.charge-name {
  display: block;
  font-weight: 700;
}

.charge-status {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.9rem;
}

.charge-date,
.charge-amount {
  white-space: nowrap;
}

.charge-date {
  color: var(--muted);
}

.charge-amount {
  font-weight: 700;
}

.charge-item.is-paid {
  color: var(--muted);
  background: #f0f4f0;
}

.charge-item.is-paid .charge-name {
  text-decoration: line-through;
}

.charge-item.is-soon {
  border-color: var(--gold);
}

.charge-item.is-late {
  border-color: var(--red);
}

.remove-charge {
  width: 32px;
  height: 32px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.money-form {
  display: grid;
  gap: 10px;
}

.money-form label {
  color: var(--muted);
  font-weight: 700;
}

.money-form input,
.money-form select,
.goal-dialog input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.money-form button,
.dialog-actions button {
  min-height: 44px;
  padding: 10px 14px;
  color: #fffaf0;
  background: var(--green-dark);
  border: 0;
  border-radius: 8px;
  font-weight: 700;
}

.money-form button:hover,
.dialog-actions button:hover {
  background: var(--green);
}

.goal-dialog {
  width: min(92vw, 420px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.goal-dialog::backdrop {
  background: rgba(28, 38, 34, 0.42);
}

.goal-dialog form {
  display: grid;
  gap: 12px;
  padding: 22px;
}

.goal-dialog label {
  color: var(--muted);
  font-weight: 700;
}

.dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.dialog-actions button[type="button"] {
  color: var(--ink);
  background: #e9eee7;
}

@media (max-width: 720px) {
  .balance-hero,
  .section-heading,
  .goal-button,
  .chart-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .balance-hero,
  .section-heading,
  .goal-button {
    align-items: start;
  }

  .goal-button {
    display: grid;
  }

  #goalSummary {
    white-space: normal;
  }

  .form-grid {
    display: grid;
  }

  .chart-block-wide {
    grid-column: auto;
  }

  .status-pills {
    justify-content: flex-start;
  }

  .charge-item {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .charge-date,
  .charge-amount {
    grid-column: 2 / span 1;
  }

  .remove-charge {
    grid-column: 3;
    grid-row: 1;
  }
}

@media (max-width: 440px) {
  .app-shell {
    width: min(100% - 20px, 980px);
    padding-top: 10px;
  }

  .balance-hero,
  .goal-section,
  .visual-section,
  .log-section,
  .money-form {
    padding: 16px;
  }

  .charge-item {
    gap: 8px;
    padding: 12px;
  }
}
