:root {
  --primary-color: #2e7d32;
  --bg-color: #f9f9f9;
  --card-bg: #ffffff;
  --text-color: #212121;
  --border-color: #e0e0e0;
  
  --paid-bg: #BAF77D;
  --paid-text: #1b5e20;
  
  --open-bg: #FB9898;
  --open-text: #7f0000;
}

* {
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  background-color: var(--bg-color);
  color: var(--text-color);
  margin: 0;
  padding: 1rem;
}

.container {
  max-width: 1300px;
  margin: 0 auto;
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

/* FIXIERTER BEREICH OVERALL (Header + Suche + Kopfzeile) */
.sticky-top-section {
  position: sticky;
  top: 0;
  background-color: var(--card-bg);
  z-index: 1000;
  padding-bottom: 0.5rem;
}

header {
  text-align: center;
  margin-bottom: 0.1rem;
  padding-bottom: 0.1rem;
}

h1 {
  font-size: 1.4rem;
  color: var(--primary-color);
  margin: 0.5rem 0;
}

.sub-info {
  font-size: 1rem;
  font-weight: 600;
  margin: 0.2rem 0;
  padding: 0;
}

.header-logos {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
}

.header-logos img {
  max-height: 60px;
  width: auto;
}

.iframe-container {
  margin-top: 0.5rem;
  width: 100%;
  text-align: center;
}

.iframe-container iframe {
  border: 0;
  width: 100%;
  height: 95px;
  overflow: hidden;
  display: block;
}

/* Suche */
.filter-container {
  margin: 0.8rem 0 0.5rem 0;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background-color: #fff;
}

.search-input:focus {
  outline: 2px solid var(--primary-color);
}

/* DESKTOP TABELLEN-LAYOUT (Konsolidiert & Synchronisiert) */
.desktop-table {
  width: 100%;
  overflow-x: auto;
}

.table-head-only, 
.desktop-table table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

/* EINHEITLICHER TABELLENKOPF */
.table-head-only th,
.desktop-table th,
table th {
  background-color: var(--primary-color) !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  text-align: left;
  padding: 0.6rem 0.5rem;
  border: 1px solid var(--border-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.desktop-table td,
.table-wrapper td {
  padding: 0.5rem 0.5rem;
  border: 1px solid var(--border-color);
  word-wrap: break-word;
  overflow-wrap: break-word;
  vertical-align: middle;
}

tr:hover {
  background-color: #f5f5f5;
}

.bg-offen {
  background-color: var(--open-bg);
}

.bg-bezahlt {
  background-color: var(--paid-bg);
}

/* MOBIL-LISTE (Pfeil-Duplikat behoben) */
.status-badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-weight: bold;
  font-size: 0.85rem;
  text-align: center;
  width: 100%;
}

.status-paid {
  background-color: var(--paid-bg);
  color: var(--paid-text);
}

.status-open {
  background-color: var(--open-bg);
  color: var(--open-text);
}

@media (max-width: 900px) {
  .container {
    padding: 0.75rem;
  }

  .desktop-table {
    display: none;
  }

  .mobile-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.8rem;
  }

  details.mobile-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
  }

  details.mobile-card[open] {
    border-color: var(--primary-color);
    background-color: #fafafa;
  }

  summary.mobile-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    cursor: pointer;
    list-style: none; /* Entfernt Firefox/Chrome Standard-Pfeile */
  }

  summary.mobile-summary::-webkit-details-marker,
  summary.mobile-summary::marker {
    display: none; /* Entfernt Safari & Chrome Marker vollständig */
    width: 0;
    height: 0;
  }

  summary.mobile-summary::after {
    content: "▼";
    font-size: 0.75rem;
    color: var(--primary-color);
    margin-left: 0.5rem;
    transition: transform 0.2s ease;
    flex-shrink: 0;
  }

  details.mobile-card[open] summary.mobile-summary::after {
    transform: rotate(180deg);
  }

  .summary-title, .summary-status {
    display: flex;
    flex-direction: column;
  }

  .summary-name {
    font-size: 0.95rem;
  }

  .summary-sub {
    font-size: 0.8rem;
    color: #666;
    font-weight: normal;
  }

  .card-details {
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px dashed var(--border-color);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    font-size: 0.85rem;
  }

  .detail-item {
    display: flex;
    flex-direction: column;
  }

  .detail-label {
    color: #777;
    font-size: 0.75rem;
  }
}

@media (min-width: 901px) {
  .mobile-list {
    display: none;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}