/* Reset some default browser styles */
body,
h1,
p,
fieldset,
legend,
form,
input,
table,
th,
td {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  vertical-align: baseline;
  box-sizing: border-box;
}

/* Basic styles */
body {
  font-family: "Arial", sans-serif;
  background-color: #f4f4f9;
  color: #333;
  line-height: 1.6;
  padding: 20px;
  max-width: 1200px; /* Adjusted max width for better desktop view */
  margin: 0 auto;
}

h1 {
  font-size: 2rem;
  color: #444;
  text-align: center;
  margin-bottom: 20px;
}

p.warning {
  background-color: #ffdddd;
  color: #d8000c;
  border-left: 6px solid #d8000c;
  padding: 10px;
  margin-bottom: 20px;
}

.share-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fff;
  border: 1px solid #e2e6ea;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.share-panel__text p {
  margin-top: 6px;
  color: #4a4a4a;
}

.share-panel__form {
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
}

.share-feedback {
  padding: 10px 12px;
  border-radius: 6px;
  margin-bottom: 12px;
  border: 1px solid transparent;
}

.share-feedback.success {
  background: #e6ffed;
  border-color: #b5e4c3;
  color: #1a7f37;
}

.share-feedback.error {
  background: #fff1f0;
  border-color: #ffc7ce;
  color: #d20032;
}

.share-result {
  margin-bottom: 20px;
}

.share-url-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}

.share-url-row input[type="text"] {
  flex: 1;
}

.copy-button {
  white-space: nowrap;
}

.balance-legend {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  background: #eef5ff;
  border: 1px solid #d8e6ff;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 20px;
}

.legend-copy p {
  margin-top: 6px;
  color: #4a4a4a;
}

.legend-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tone-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: bold;
  font-size: 0.9rem;
}

.tone-pill.debt {
  background: #fff1f0;
  color: #d20032;
}

.tone-pill.credit {
  background: #e6ffed;
  color: #1a7f37;
}

.tone-pill.even {
  background: #f2f3f5;
  color: #555;
}

.tag {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.8rem;
  background: #eef1ff;
  color: #3949ab;
  border: 1px solid #d9defa;
  margin-left: 6px;
}

.bank-tag {
  background: #f1ebff;
  border-color: #d7ccff;
  color: #5a3ec8;
}

fieldset {
  border: 1px solid #ccc;
  padding: 20px;
  margin-bottom: 20px;
  border-radius: 5px;
  background-color: #fff;
}

/* Fieldset styling for desktop */
.fieldset-container {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.fieldset-container fieldset {
  flex: 1 1 100%;
  max-width: 100%;
}

/* Styling for fieldset in mobile view */
@media (max-width: 768px) {
  .fieldset-container {
    flex-direction: column;
  }

  .fieldset-container fieldset {
    max-width: 100%;
  }
}

legend {
  font-weight: bold;
  font-size: 1.2rem;
  color: #333;
  margin-bottom: 10px;
}

form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

label {
  font-weight: bold;
  margin-bottom: 5px;
}

input[type="text"],
input[type="number"],
select {
  padding: 10px;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 5px;
  width: 100%;
}

input[type="submit"] {
  background-color: #007bff;
  color: #fff;
  border: none;
  padding: 10px;
  font-size: 1rem;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

button {
  background-color: #007bff;
  color: #fff;
  border: none;
  padding: 10px 14px;
  font-size: 1rem;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

button:hover {
  background-color: #0056b3;
}

input[type="submit"].reset {
  background-color: #dc3545;
}

input[type="submit"]:hover {
  background-color: #0056b3;
}

input[type="submit"].reset:hover {
  background-color: #c82333;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}

th,
td {
  padding: 10px;
  border: 1px solid #ccc;
  text-align: left;
}

th {
  background-color: #f9f9f9;
}

td form {
  display: inline-block;
}

td form input[type="submit"] {
  background-color: #dc3545;
  border: none;
  padding: 5px 10px;
  font-size: 0.9rem;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

td form input[type="submit"]:hover {
  background-color: #c82333;
}

.payment-impact-cell details summary {
  cursor: pointer;
  padding: 10px 12px;
  background: #f7f8fa;
  border: 1px solid #e2e6ea;
  border-radius: 6px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: 4px;
  list-style: none;
}

.payment-impact-cell details[open] summary {
  border-color: #007bff;
  background: #eef5ff;
}

.summary-impact {
  color: #666;
  font-size: 0.9rem;
}

.impact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.impact-card {
  border: 1px solid #e2e6ea;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

.impact-card.debt {
  border-color: #ffc7ce;
  background: #fff7f7;
}

.impact-card.credit {
  border-color: #c5e8cf;
  background: #f7fffa;
}

.impact-card.even {
  border-color: #e0e0e0;
}

.impact-card__title {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.impact-card__delta {
  color: #555;
  margin-bottom: 4px;
}

.impact-card__after {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.impact-table-wrapper {
  overflow-x: auto;
}

.impact-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  min-width: 500px;
}

.impact-table th,
.impact-table td {
  border: 1px solid #e2e6ea;
  padding: 8px;
  text-align: left;
}

.impact-table th:first-child,
.impact-table td:first-child {
  width: 30%;
}

.impact-balance {
  font-weight: 600;
}

.tone-block {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid transparent;
}

.tone-block.debt {
  background: #fff1f0;
  color: #d20032;
  border-color: #ffc7ce;
}

.tone-block.credit {
  background: #e6ffed;
  color: #1a7f37;
  border-color: #b5e4c3;
}

.tone-block.even {
  background: #f2f3f5;
  color: #555;
  border-color: #e0e0e0;
}

.impact-delta {
  font-size: 0.9rem;
  color: #333;
  margin-top: 4px;
}

/* Responsive design */
@media (max-width: 600px) {
  h1 {
    font-size: 1.5rem;
  }

  form {
    flex-direction: column;
  }

  table,
  thead,
  tbody,
  th,
  td,
  tr {
    display: block;
    width: 100%;
  }

  th,
  td {
    text-align: left;
    padding: 10px;
  }

  thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }

  tr {
    margin-bottom: 10px;
  }

  tr:before {
    content: " ";
    display: table;
  }

  tr:after {
    content: " ";
    display: table;
    clear: both;
  }

  th,
  td {
    padding: 10px;
    border: none;
    position: relative;
    padding-left: 50%;
    text-align: right;
  }

  td:before,
  th:before {
    position: absolute;
    left: 10px;
    width: calc(50% - 20px);
    white-space: nowrap;
    content: attr(data-label);
    text-align: left;
    font-weight: bold;
  }

  .balance-legend {
    flex-direction: column;
  }

  .share-panel {
    flex-direction: column;
    align-items: flex-start;
  }

  .share-url-row {
    flex-direction: column;
    align-items: stretch;
  }

  .copy-button {
    width: 100%;
  }

  /* Keep the brede betalingen-tabel in echte tabelvorm; laat horizontaal scrollen via wrapper */
  .payments-table,
  .payments-table thead,
  .payments-table tbody,
  .payments-table th,
  .payments-table td,
  .payments-table tr {
    display: table;
    width: auto;
  }

  .payments-table thead tr {
    position: static;
  }

  .payments-table th,
  .payments-table td {
    padding-left: 8px;
    text-align: left;
  }

  .payments-table td:before,
  .payments-table th:before {
    content: none;
  }
}
