:root {
  color-scheme: light;
  --bg: #f5f6f3;
  --surface: #ffffff;
  --surface-soft: #fafbf8;
  --text: #1f2824;
  --muted: #66706b;
  --line: #d8ded8;
  --accent: #24594d;
  --accent-soft: #e8f0ec;
  --warning: #8b5e34;
  --danger: #a33b3b;
  --shadow: 0 18px 50px rgba(32, 42, 36, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

a {
  color: var(--accent);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  font-size: 24px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 17px;
}

.header-actions,
.toolbar,
.toolbar-left,
.toolbar-actions,
.modal-actions,
.modal-footer-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar {
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.toolbar-left {
  min-width: 0;
}

.toolbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.subtle {
  margin-top: 2px;
  color: var(--muted);
}

button,
.icon-text {
  min-height: 36px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.icon-text {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 6px;
  font-size: 18px;
  line-height: 1;
}

.secondary,
.ghost {
  background: #fff;
  color: var(--accent);
}

.danger {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}

.tabs {
  display: flex;
  gap: 2px;
  padding: 8px 24px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.tab {
  min-height: 38px;
  padding: 8px 14px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}

.tab.active {
  border-bottom-color: var(--accent);
  color: var(--text);
}

.workspace {
  padding: 16px 24px 28px;
}

.tab-panel {
  display: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.tab-panel.active {
  display: block;
}

.messages {
  padding: 10px 24px 0;
}

.message {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.message.info {
  border-color: #98b8aa;
  color: var(--accent);
}

.message.error {
  border-color: #c88;
  color: var(--danger);
}

.calendar-grid {
  background: var(--surface);
}

.weekday,
.calendar-day {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.weekday:nth-child(7),
.calendar-day:nth-child(7n) {
  border-right: 0;
}

.weekday {
  display: inline-flex;
  align-items: center;
  height: 34px;
  width: calc(100% / 7);
  padding: 0 10px;
  background: #eef2ed;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(118px, 1fr));
}

.calendar-day {
  min-height: 132px;
  padding: 8px;
  background: var(--surface);
  text-align: left;
  vertical-align: top;
  border-top: 0;
  border-left: 0;
  color: var(--text);
  font-weight: 400;
}

.calendar-day:hover {
  background: var(--surface-soft);
}

.calendar-day.outside {
  background: #f0f2ef;
  color: #9aa39d;
}

.date-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 24px;
  border-radius: 5px;
  font-weight: 800;
}

.calendar-day.today .date-number {
  background: var(--accent);
  color: #fff;
}

.day-events {
  display: grid;
  gap: 5px;
  margin-top: 7px;
}

.event-chip {
  display: block;
  width: 100%;
  padding: 5px 6px;
  border: 1px solid #cfd8d2;
  border-left: 4px solid var(--accent);
  border-radius: 5px;
  background: #fff;
  color: var(--text);
  text-align: left;
  font-size: 12px;
  font-weight: 700;
}

.event-chip small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.event-chip.kind-eucharistie {
  border-left-color: #24594d;
}

.event-chip.kind-wortliturgie,
.event-chip.kind-psalm {
  border-left-color: #436a94;
}

.event-chip.kind-bußliturgie,
.event-chip.kind-termin {
  border-left-color: #a33b3b;
}

.event-chip.kind-gemeinschaftstag,
.event-chip.kind-pfingstvigil {
  border-left-color: #8b5e34;
}

.event-chip.is-highlighted {
  border-color: #ff1f1f;
  border-left-color: #e00000;
  background: #ffe7e7;
  color: #710000;
}

.event-chip.is-highlighted small {
  color: #8f1616;
}

.list-table-wrap {
  overflow: auto;
  max-height: calc(100vh - 210px);
}

.list-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef2ed;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tbody tr:hover {
  background: var(--surface-soft);
}

.status-col,
.action-col {
  width: 64px;
  text-align: center;
}

.berlin-badge {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: #9aa39d;
  font-size: 18px;
  font-weight: 800;
}

.berlin-badge.is-in {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.row-note {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.modal {
  width: min(780px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(22, 28, 25, 0.38);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

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

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  text-transform: none;
}

select[multiple],
textarea {
  min-height: 112px;
}

textarea {
  resize: vertical;
}

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

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  color: var(--text);
  font-size: 14px;
  text-transform: none;
}

.check-row input {
  width: auto;
  min-height: auto;
}

.red-check {
  color: #9d0000;
}

.modal-actions,
.modal-footer-row {
  justify-content: flex-end;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}

.modal-footer-row {
  justify-content: space-between;
}

.modal-delete {
  padding: 0 16px 16px;
}

.modal-delete[hidden],
.modal-footer-row[hidden],
#event-suggest-form[hidden],
#event-delete-form[hidden] {
  display: none;
}

.original-group,
.suggestion-line {
  margin: 0 16px 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
}

.original-group:empty,
.suggestion-line:empty {
  display: none;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.login-form {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

@media (max-width: 900px) {
  .app-header,
  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .workspace,
  .tabs,
  .app-header {
    padding-left: 12px;
    padding-right: 12px;
  }

  .toolbar-actions {
    justify-content: flex-start;
  }

  .workspace {
    padding-top: 12px;
  }

  .weekday {
    display: none;
  }

  .calendar-days {
    display: block;
  }

  .calendar-day {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    width: 100%;
    min-height: 48px;
    padding: 9px 10px;
    border-right: 0;
  }

  .calendar-day:nth-child(7n) {
    border-right: 0;
  }

  .calendar-day.outside {
    display: none;
  }

  .date-number {
    width: 30px;
  }

  .day-events {
    min-width: 0;
    margin-top: 0;
  }

  .calendar-day:not(.has-events) .day-events::before {
    content: "Termin hinzufügen";
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
  }

  .event-chip {
    min-height: 36px;
    font-size: 13px;
  }

  .list-table-wrap {
    overflow: visible;
    max-height: none;
  }

  .list-table {
    min-width: 0;
  }

  .list-table,
  .list-table tbody,
  .list-table tr,
  .list-table td {
    display: block;
    width: 100%;
  }

  .list-table thead {
    display: none;
  }

  .list-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
  }

  .list-table td {
    padding: 2px 0;
    border: 0;
  }

  .list-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 1px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .list-table td[data-label="Name"] {
    grid-column: 1;
    grid-row: 1;
  }

  .list-table td[data-label="Berlin"],
  .list-table td[data-label="Aktion"] {
    grid-column: 2;
    width: auto;
    text-align: right;
  }

  .list-table td[data-label="Berlin"] {
    grid-row: 1;
  }

  .list-table td[data-label="Aktion"] {
    grid-row: 2;
  }

  .list-table td[data-label="E-Mail"],
  .list-table td[data-label="Telefon"],
  .list-table td[data-label="Adresse"],
  .list-table td[data-label="Liste"] {
    grid-column: 1 / -1;
  }

  .status-col,
  .action-col {
    width: auto;
  }

  .modal-footer-row {
    align-items: stretch;
    flex-direction: column;
  }
}
