:root {
  --bg: #f6f7f3;
  --bg-2: #edf0e5;
  --panel: #ffffff;
  --text: #132318;
  --muted: #5d6f61;
  --accent: #0f7f4f;
  --accent-2: #1f6feb;
  --danger: #9a2a2a;
  --line: #d9ddd2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 10%, #dff0d6 0%, transparent 35%),
    radial-gradient(circle at 90% 0%, #e4ecff 0%, transparent 30%),
    var(--bg);
}

h1,
h2,
h3 {
  margin-top: 0;
}

h1 {
  font-size: clamp(1.3rem, 2vw + 1rem, 2rem);
}

h2 {
  font-size: 1.15rem;
}

h3 {
  font-size: 1rem;
  margin-bottom: 0.6rem;
}

.topbar {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(120deg, #f9fff2, #f2f8ff);
}

.inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

.eyebrow {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 10px 30px rgba(28, 49, 35, 0.06);
}

.sticky {
  position: sticky;
  top: 0.8rem;
}

label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.6rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  margin-top: 0.3rem;
  font: inherit;
  background: #fff;
}

/* Read-only-Ansicht: alle Steuerelemente zum Aendern ausblenden */
body.readonly #addFamily,
body.readonly #addExtra,
body.readonly .remove-family,
body.readonly .add-family-extra,
body.readonly #extras .icon-btn,
body.readonly .family-extras .icon-btn {
  display: none;
}

body.readonly input:disabled,
body.readonly select:disabled,
body.readonly textarea:disabled {
  opacity: 1;
  cursor: default;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  padding-left: 0;
  color: inherit;
  -webkit-text-fill-color: inherit;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: textfield;
}

body.readonly input[type="number"]:disabled::-webkit-inner-spin-button,
body.readonly input[type="number"]:disabled::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

textarea {
  font-family: "IBM Plex Mono", monospace;
}

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

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
}

.inline-row {
  display: flex;
  gap: 0.7rem;
}

.family-row {
  border: 1px solid var(--line);
  background: var(--bg-2);
  border-radius: 12px;
  padding: 0.8rem;
  margin-bottom: 0.7rem;
}

.family-row .grid-3,
.family-row .family-paid-label {
  margin-bottom: 0.7rem;
}

.family-groups,
.family-more-groups {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.family-more-groups:empty {
  margin-bottom: 0;
}

.family-group {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.7rem 0;
  background: #fcfdf9;
}

.family-group .grid-3 {
  margin-bottom: 0.7rem;
  align-items: end;
}

.family-groups .family-group:only-child .remove-group {
  display: none;
}

.family-more-groups-block {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  background: #fcfdf9;
  margin-bottom: 0.7rem;
}

.family-more-groups-block summary {
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.family-more-groups-block .hint {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0.4rem 0 0.6rem;
}

.family-more-groups-block[open] summary {
  margin-bottom: 0.3rem;
}

.more-groups-badge {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
}

.family-more-groups-block .add-group {
  margin-top: 0.2rem;
}

.family-contact-row {
  align-items: end;
  margin-bottom: 0.7rem;
}

.send-payment-request {
  height: fit-content;
  white-space: nowrap;
}

.send-payment-request:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.family-payout-block {
  border: 1px solid #bfe3cb;
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
  background: #f2faf4;
  margin-bottom: 0.7rem;
}

.family-payout-block .payout-hint {
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.family-payout-block .checkbox-label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  font-weight: 400;
}

.family-payout-block .checkbox-label input {
  width: auto;
}

.family-payout-block .payout-warning {
  color: var(--danger);
  font-size: 0.8rem;
  font-weight: 600;
  margin: 0.5rem 0 0;
}

.family-paid-label {
  max-width: 220px;
}

.row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}

.family-title {
  font-size: 0.95rem;
  flex: 1;
}

.family-balance-badge {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--muted);
}

.family-balance-badge.negative {
  background: #fbebeb;
  border-color: #e3c2c2;
  color: var(--danger);
}

.family-balance-badge.positive {
  background: #e7f6ec;
  border-color: #bfe3cb;
  color: var(--accent);
}

.family-extras-block {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  background: #fcfdf9;
}

.family-extras-block summary {
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.family-extras-block .hint {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0.4rem 0 0.6rem;
}

.family-extras-block[open] summary {
  margin-bottom: 0.3rem;
}

.extras-sum-badge {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
}

button {
  font: inherit;
  cursor: pointer;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.icon-btn {
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 0.6rem 0.9rem;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
}

.secondary-btn {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}

.ghost-btn {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
  text-decoration: none;
}

.icon-btn {
  background: #fff;
  border-color: #e3c2c2;
  color: var(--danger);
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
}

.block {
  margin: 0.85rem 0;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fcfdf9;
}

.summary {
  background: #0f2519;
  color: #eafff1;
  border-radius: 12px;
  padding: 0.9rem;
  font-size: 0.88rem;
  line-height: 1.4;
}

.summary-event-header {
  font-weight: 700;
  font-size: 0.95rem;
  color: #eafff1;
  margin-bottom: 0.6rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.stat-grid {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.8rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.stat {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
}

.stat span {
  color: #a9c9b3;
}

.stat strong {
  font-variant-numeric: tabular-nums;
}

.summary-family-list {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.summary-family-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
}

.sf-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 700;
  gap: 0.6rem;
}

.sf-extras,
.sf-paid {
  color: #a9c9b3;
  font-size: 0.82rem;
  margin-top: 0.2rem;
}

.sf-balance {
  margin-top: 0.3rem;
  font-size: 0.82rem;
  font-weight: 600;
}

.sf-balance.negative {
  color: #ff9d9d;
}

.sf-balance.positive {
  color: #8fe6ab;
}

.sf-balance.neutral {
  color: #a9c9b3;
}

.summary-totals {
  display: grid;
  gap: 0.35rem;
  padding: 0.7rem 0;
  margin-bottom: 0.8rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.summary-totals .stat.total strong {
  font-size: 1rem;
}

.summary-settlement h4 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: #eafff1;
}

.summary-settlement .muted {
  color: #a9c9b3;
  font-size: 0.84rem;
  margin: 0;
}

.settlement-hint {
  color: #a9c9b3;
  font-size: 0.78rem;
  margin: 0 0 0.6rem;
  line-height: 1.35;
}

.settlement-surcharge-info {
  margin: 0 0 0.8rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.12);
}

.settlement-done-label {
  margin: 0.7rem 0 0.4rem;
}

.settlement-manual-form {
  margin-top: 0.9rem;
  padding-top: 0.7rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.settlement-manual-title {
  color: #a9c9b3;
  font-size: 0.84rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.settlement-manual-form label {
  font-size: 0.8rem;
  margin-bottom: 0;
}

.settlement-manual-form input,
.settlement-manual-form select {
  color: var(--text);
}

.settlement-manual-form .icon-btn {
  margin-top: 0.6rem;
}

.settlement-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}

.settlement-list li {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font-size: 0.85rem;
}

.settlement-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.settlement-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.settlement-check input {
  width: auto;
  margin: 0;
  cursor: pointer;
}

.settlement-list .from,
.settlement-list .to {
  font-weight: 600;
}

.settlement-list .arrow {
  color: #a9c9b3;
}

.settlement-list strong {
  margin-left: auto;
  color: #8fe6ab;
}

.settlement-payout {
  font-size: 0.78rem;
  color: #a9c9b3;
  padding-left: 1.7rem;
}

.settlement-payout a {
  color: inherit;
}

.settlement-payout.missing {
  color: #e8a4a4;
  font-weight: 600;
}

.settlement-list.done li {
  background: rgba(255, 255, 255, 0.02);
  opacity: 0.7;
}

.settlement-list.done .from,
.settlement-list.done .to {
  text-decoration: line-through;
  font-weight: 500;
}

.settlement-list.done strong {
  color: #a9c9b3;
}

body.readonly .settlement-check input {
  pointer-events: none;
}


.status {
  margin-top: 0.6rem;
  font-size: 0.86rem;
  color: var(--muted);
}

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

.admin-inline-note {
  font-size: 0.8rem;
  margin: 0.5rem 0 0.2rem;
}

.text-btn {
  border: 0;
  background: transparent;
  color: #2f5d47;
  text-decoration: underline;
  padding: 0;
  margin-left: 0.25rem;
  font-size: 0.8rem;
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sticky {
    position: static;
  }
}

@media (max-width: 680px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .family-paid-label {
    max-width: none;
  }
}
