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

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

@media (min-width: 769px) {
  .sticky-header {
    position: sticky;
    top: 0;
  }
}

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

@media (min-width: 601px) {
  .header-top {
    flex-direction: row;
  }
}

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

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

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

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

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

@media (max-width: 600px) {
  .summary {
    max-width: 100%;
    gap: 1rem;
    padding: 0.5em;
    flex-direction: row;
    justify-content: space-between;
  }
}

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

@media (max-width: 600px) {
  .summary > div {
    flex: 1 1 100px;
  }
}

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

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

input[type="number"],
input[type="text"] {
  width: 100%;
  max-width: 120px;
  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;
}

@media (max-width: 600px) {
  #chart {
    max-width: 100%;
  }
}

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

.income-table td,
.expense-table td {
  padding: 0.4em 0;
  vertical-align: middle;
}

.income-table td:nth-child(2),
.expense-table td:nth-child(2) {
  text-align: right;
}

.income-table td input,
.expense-table td input {
  max-width: 120px;
  width: 100%;
  text-align: right;
  padding: 0.3em 0.4em;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
}


/* Mobil layout: td bliver flex-container */
@media (max-width: 600px) {
  .income-table td,
  .expense-table td,
  .extra-field td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1em;
  }

  .income-table td input,
  .expense-table td input,
  .extra-field td input {
    width: auto;
    max-width: 120px;
    margin-left: auto;
  }
}


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

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

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

@media (max-width: 600px) {
  .add-expense {
    max-width: 100%;
  }
}

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