:root {
  --red: #f00000;
  --red-deep: #a90000;
  --yellow: #fff06a;
  --yellow-strong: #ffe100;
  --ink: #1d1212;
  --paper: #fffaf0;
  --line: rgba(29, 18, 18, 0.18);
  --muted: rgba(29, 18, 18, 0.68);
  --shadow: 0 16px 38px rgba(72, 0, 0, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--red);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(255, 240, 106, 0.16), transparent 34%),
    linear-gradient(180deg, #ff1717 0%, var(--red) 42%, var(--red-deep) 100%);
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
.ghost-link {
  border: 0;
  border-radius: 8px;
  background: var(--yellow-strong);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  line-height: 1;
  min-height: 42px;
  padding: 0 16px;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

button:hover,
.ghost-link:hover {
  background: #fff8a6;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
  transform: translateY(-1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
  transform: none;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 190px;
  padding: 12px;
  resize: vertical;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px clamp(14px, 3vw, 32px);
}

.top-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.brand {
  display: inline-flex;
  align-items: center;
  color: var(--yellow);
  gap: 12px;
  min-width: 0;
  text-decoration: none;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
}

.brand img {
  flex: 0 0 auto;
  height: 56px;
  width: 56px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: clamp(1.1rem, 3vw, 1.55rem);
  line-height: 1;
}

.brand small {
  color: #fff8a6;
  font-size: 0.94rem;
  font-weight: 800;
  margin-top: 4px;
  text-transform: uppercase;
}

.app-shell,
.admin-shell {
  display: grid;
  gap: 18px;
  margin: 0 auto;
  max-width: 1440px;
  padding: 0 clamp(14px, 3vw, 32px) 32px;
}

.app-shell {
  grid-template-columns: minmax(320px, 0.42fr) minmax(420px, 0.58fr);
}

.lane-picker-panel {
  grid-column: 1 / -1;
}

.admin-shell {
  grid-template-columns: repeat(2, minmax(320px, 1fr));
}

.auth-shell {
  margin: 0 auto;
  max-width: 520px;
  padding: 0 clamp(14px, 3vw, 32px) 32px;
}

.auth-panel {
  display: grid;
  gap: 4px;
}

.auth-form {
  display: grid;
  gap: 10px;
}

.admin-shell > :last-child {
  grid-column: 1 / -1;
}

.panel {
  background: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
  padding: clamp(16px, 2vw, 22px);
}

.section-head {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-head h1,
.section-head h2,
.section-head p {
  margin: 0;
}

.section-head h1,
.section-head h2 {
  color: var(--red-deep);
  font-size: clamp(1.28rem, 2.4vw, 1.88rem);
  line-height: 1.05;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.lane-list {
  align-items: stretch;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.lane-tab,
.training-day-button {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--ink);
  min-height: 40px;
}

.lane-tab.is-active,
.training-day-button.is-active {
  background: var(--red);
  border-color: var(--red);
  color: var(--yellow);
}

.training-days {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  margin-bottom: 16px;
}

.training-day-card {
  align-items: flex-start;
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--ink);
  display: grid;
  gap: 14px;
  justify-items: start;
  min-height: 108px;
  padding: 14px;
  text-align: left;
}

.training-day-card strong {
  align-self: end;
  background: #fff3c5;
  border-radius: 999px;
  color: var(--red-deep);
  font-size: 1.2rem;
  min-width: 38px;
  padding: 7px 10px;
  text-align: center;
}

.training-day-card.is-active {
  background: var(--red);
  border-color: var(--red);
  color: var(--yellow);
}

.training-day-card.is-active strong {
  background: var(--yellow);
  color: var(--red-deep);
}

.detail-empty,
.empty-state {
  align-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: flex;
  justify-content: center;
  min-height: 140px;
  text-align: center;
}

.lane-title-row,
.training-title-row {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.lane-title-row h2,
.training-title-row h2 {
  font-size: clamp(1.2rem, 2.2vw, 1.65rem);
  line-height: 1.1;
  margin: 0;
}

.lane-title-row p,
.training-title-row p {
  color: var(--muted);
  margin: 4px 0 0;
}

.add-default-form,
.default-select-form,
.add-person-form,
.date-form,
.inline-form {
  align-items: center;
  display: flex;
  gap: 8px;
}

.inline-form {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.inline-form input[type="number"] {
  max-width: 118px;
}

.add-default-form,
.default-select-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  margin-bottom: 14px;
}

.searchable-select {
  display: grid;
  gap: 8px;
  min-width: 0;
  position: relative;
}

.searchable-select input,
.searchable-select select {
  min-width: 0;
}

.searchable-select select[hidden] {
  display: none;
}

.combo-results {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(72, 0, 0, 0.18);
  display: grid;
  left: 0;
  max-height: 260px;
  overflow-y: auto;
  padding: 6px;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
}

.combo-results[hidden] {
  display: none;
}

.combo-option {
  background: #ffffff;
  border-radius: 6px;
  color: var(--ink);
  justify-content: flex-start;
  line-height: 1.25;
  min-height: 38px;
  padding: 9px 10px;
  text-align: left;
}

.combo-option:hover,
.combo-option.is-active {
  background: var(--red);
  box-shadow: none;
  color: var(--yellow);
  transform: none;
}

.combo-empty {
  color: var(--muted);
  font-weight: 800;
  padding: 10px;
}

.add-person-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  margin-bottom: 14px;
}

.date-form input {
  max-width: 168px;
}

.icon-button,
.inline-form button {
  align-items: center;
  display: inline-flex;
  font-size: 1.25rem;
  justify-content: center;
  min-width: 42px;
  padding: 0;
}

.refresh-button {
  font-size: 1.2rem;
}

.default-list,
.attendee-grid,
.archived-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.name-chip,
.attendee-toggle {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-flex;
  gap: 8px;
  min-height: 40px;
  padding: 7px 8px 7px 12px;
}

.name-chip button {
  align-items: center;
  background: #ffe5e5;
  color: var(--red-deep);
  display: inline-flex;
  font-size: 1.1rem;
  justify-content: center;
  min-height: 28px;
  min-width: 28px;
  padding: 0;
}

.chip-main {
  font-weight: 800;
}

.status-badge {
  border-radius: 999px;
  background: #f2f0e7;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  max-width: 170px;
  overflow: hidden;
  padding: 4px 7px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-badge[data-status="Aktiv"] {
  background: #e5f7e7;
  color: #176b2b;
}

.status-badge[data-status="Kein Mitglied"],
.status-badge[data-status="ERFASST / Kein Mitglied"] {
  background: #fff3c5;
  color: #7a4c00;
}

.status-badge[data-status="gekündigt"] {
  background: #ececec;
  color: #555555;
}

.training-detail {
  display: grid;
  gap: 12px;
}

.training-lane {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.training-lane:first-child {
  border-top: 0;
  padding-top: 0;
}

.training-lane h3 {
  color: var(--red-deep);
  font-size: 1.04rem;
  line-height: 1.2;
  margin: 0 0 10px;
}

.attendee-toggle {
  background: #ffffff;
  color: var(--ink);
  font-weight: 800;
  justify-content: space-between;
  line-height: 1.1;
  max-width: 100%;
  min-width: 142px;
  padding: 10px 12px;
}

.attendee-toggle.is-selected {
  background: var(--red);
  color: var(--yellow);
}

.attendee-toggle .checkmark {
  border: 2px solid currentColor;
  border-radius: 6px;
  display: inline-grid;
  flex: 0 0 24px;
  height: 24px;
  place-items: center;
  width: 24px;
}

.attendee-toggle.is-selected .checkmark::before {
  content: "✓";
  font-weight: 900;
}

.lane-note,
.archive-note {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 8px 0 0;
}

.archive-note {
  margin: 12px 0 8px;
}

.admin-list {
  display: grid;
  gap: 8px;
}

.user-create-form {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(140px, 1fr) minmax(140px, 1fr) auto auto;
  margin-bottom: 12px;
}

.checkbox-label {
  align-items: center;
  display: inline-flex;
  gap: 8px;
  font-weight: 900;
  min-height: 42px;
  white-space: nowrap;
}

.checkbox-label input {
  accent-color: var(--red);
  height: 18px;
  min-height: 0;
  width: 18px;
}

.admin-row {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto auto;
  padding: 8px;
}

.admin-row.lane-row {
  grid-template-columns: minmax(150px, 1fr) minmax(100px, 140px) minmax(100px, 140px) minmax(150px, 190px) auto;
}

.admin-row.is-saving {
  opacity: 0.72;
}

.admin-row input,
.admin-row select {
  min-width: 0;
}

.permission-menu {
  min-width: 0;
  position: relative;
}

.permission-menu summary {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  font-weight: 900;
  justify-content: space-between;
  min-height: 42px;
  padding: 0 12px;
}

.permission-menu-body {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(72, 0, 0, 0.18);
  display: grid;
  gap: 4px;
  left: 0;
  margin-top: 6px;
  max-height: 260px;
  min-width: 220px;
  overflow-y: auto;
  padding: 8px;
  position: absolute;
  right: 0;
  z-index: 22;
}

.permission-menu-body .checkbox-label {
  border-radius: 6px;
  min-height: 34px;
  padding: 6px;
}

.permission-menu-body .checkbox-label:hover {
  background: #fff3c5;
}

.admin-row .danger {
  background: #ffe5e5;
  color: var(--red-deep);
}

.danger,
.subtle-danger {
  background: #ffe5e5;
  color: var(--red-deep);
}

.people-admin-list .admin-row,
.admin-row.person-row {
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) minmax(132px, 0.8fr) auto minmax(150px, 220px) auto;
}

.user-admin-list .admin-row,
.admin-row.user-row {
  grid-template-columns: minmax(150px, 1fr) auto minmax(150px, 1fr) auto auto;
}

.person-status-display {
  align-items: center;
  display: inline-flex;
  min-height: 42px;
}

.recent-list {
  display: grid;
  gap: 8px;
}

.recent-row {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) auto;
  padding: 10px;
}

.recent-row small {
  color: var(--muted);
  font-weight: 800;
}

.file-upload {
  align-items: center;
  background: #ffffff;
  border: 1px dashed var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  font-weight: 900;
  justify-content: center;
  min-height: 96px;
  padding: 16px;
  text-align: center;
}

.file-upload:hover {
  border-color: var(--red);
}

.file-upload input {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.merge-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.notice {
  background: #fff8c8;
  border: 1px solid #ead55b;
  border-radius: 8px;
  color: #5c3d00;
  font-weight: 800;
  margin-top: 12px;
  padding: 12px;
}

.filter-input {
  max-width: 260px;
}

.is-hidden {
  display: none;
}

@media (max-width: 960px) {
  .app-shell,
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .lane-picker-panel {
    grid-column: auto;
  }

  .admin-shell > :last-child {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  .topbar,
  .section-head,
  .lane-title-row,
  .training-title-row {
    align-items: stretch;
    flex-direction: column;
  }

  .ghost-link,
  .date-form,
  .inline-form {
    width: 100%;
  }

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

  .date-form input {
    max-width: none;
  }

  .admin-row,
  .admin-row.lane-row,
  .people-admin-list .admin-row,
  .admin-row.person-row,
  .user-create-form,
  .user-admin-list .admin-row,
  .admin-row.user-row,
  .merge-grid,
  .recent-row {
    grid-template-columns: 1fr;
  }

  .add-default-form,
  .default-select-form,
  .add-person-form {
    grid-template-columns: 1fr;
  }

  button,
  .ghost-link {
    justify-content: center;
  }
}
