body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
}

.sticky-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: white;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  max-width: 480px; /* Smallere header max-width */
  margin: 0 auto;
  padding: 0.5em 1em;
  border-bottom: 1px solid #ddd;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #eee;
  flex-wrap: wrap;
  padding: 0.5em 0;
  gap: 0.5em;
}

.header-top h1 {
  font-size: 1.3rem;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.header-top button {
  padding: 0.4em 1em;
  font-size: 0.9rem;
  background-color: #e53935;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.header-top button:hover {
  background-color: #c62828;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.summary {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: #f4f4f4;
  padding: 0.6em 0.8em;
  font-weight: bold;
  gap: 0.5em;
  flex-wrap: wrap;
  text-align: center; /* centrer summary tekst */
  max-width: 480px;
  margin: 0.6em auto 0 auto;
}

.summary > div {
  flex: 1 1 30%;
  min-width: 100px;
  text-align: center;
}

.yearly {
  font-size: 0.75rem;
  color: #555;
  display: block;
  margin-top: 0.25em;
}

section {
  padding: 1em;
  max-width: 480px; /* smallere sektioner */
  margin: 1em auto 2em auto;
}

input[type="number"],
input[type="text"] {
  width: 100%;
  max-width: 120px; /* lidt større input på desktop */
  text-align: right;
  padding: 0.3em 0.4em;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
  font-size: 0.95rem;
}

#chart {
  display: block;
  margin: 1em auto;
  max-width: 90vw;
  max-height: 250px;
  height: auto !important;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1em;
}

td {
  padding: 0.5em;
  vertical-align: middle;
  font-size: 0.95rem;
}

fieldset {
  border: 1px solid #ccc;
  padding: 1em;
  margin-bottom: 1.2em;
  border-radius: 8px;
}

legend {
  font-weight: bold;
  padding: 0 0.5em;
}

.income-table input[type="number"],
#expenses input[type="number"] {
  width: 100%;
  box-sizing: border-box;
  text-align: right;
}

button {
  background-color: #e53935;
  color: white;
  border: none;
  padding: 0.6em 1.2em;
  border-radius: 8px;
  font-size: 1em;
  cursor: pointer;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
  background-color: #c62828;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

button:active {
  background-color: #b71c1c;
}

.expense-category {
  margin-bottom: 2em;
  border-top: 1px solid #ddd;
  padding-top: 1em;
}

.add-expense {
  margin-top: 0.5em;
  background-color: #1976d2;
  color: white;
  border: none;
  padding: 0.5em 1em;
  border-radius: 6px;
  cursor: pointer;
  width: 100%;
  max-width: 300px;
  transition: background-color 0.2s ease;
}

.add-expense:hover {
  background-color: #1565c0;
}

@media (max-width: 600px) {
  .sticky-header {
    max-width: 100%;
    padding: 0.5em 1em;
  }

  .summary {
    flex-direction: row;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    max-width: 100%;
    padding: 0.5em;
  }

  .summary > div {
    flex: 1 1 100px;
  }

  .header-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5em;
    padding: 0.4em 0;
  }

  table {
    width: 100%;
    display: block;
    overflow-x: auto;
  }

  td {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 0.4em 0;
  }

  td input {
    width: 100%;
    text-align: right;
  }

  fieldset {
    padding: 1em 0.5em;
  }

  canvas#chart {
    max-width: 100%;
    height: auto !important;
  }

  .add-expense {
    max-width: 100%;
  }
}

td:last-child {
  text-align: right;
  width: 100%;
}

td:last-child input {
  float: right;
}

/* Forhindrer tekstombrydning i venstre kolonne i alle tabeller */
td:first-child {
  white-space: nowrap;
}