.portal-page {
  min-height: 100vh;
  display: flex;
  background: #f4f8f9;
}
/* Seitenleiste im Look der Website-Navigation (dunkles Petrol),
   damit das weisse Logo sichtbar ist und Portal + Website zusammenpassen. */
.portal-sidebar {
  width: 240px;
  background: linear-gradient(180deg, #1a3d4f 0%, #14303f 100%);
  border-right: 1px solid #14303f;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.portal-logo {
  display: block;
  text-align: center;
  margin: -0.5rem -0.25rem 0.75rem;
  padding: 0.25rem;
  border-radius: 10px;
}
.portal-logo img { height: 140px; width: auto; max-width: 100%; object-fit: contain; }
.portal-logo:hover { background: rgba(255, 255, 255, 0.06); }
.portal-user {
  text-align: center;
  font-size: 0.85rem;
  color: #a9c8d3;
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.portal-user strong { display: block; font-size: 0.95rem; color: #fff; }
.portal-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.portal-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  color: #cfe3ea;
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.portal-nav-item .ti { font-size: 18px; color: #8fb6c2; flex-shrink: 0; }
.portal-nav-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.portal-nav-item:hover .ti { color: #fff; }
.portal-nav-item.active { background: #1d6e80; color: #fff; font-weight: 600; }
.portal-nav-item.active .ti { color: #fff; }
.portal-nav-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 0.6rem;
}
.portal-nav-group {
  padding: 0.9rem 12px 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: #7fa5b3;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.portal-copyright {
  font-size: 0.72rem;
  color: #6f96a4;
  text-align: center;
  padding: 0.75rem 1rem 0.5rem;
}
.portal-main {
  flex: 1;
  padding: 2.5rem 3rem;
  max-width: 1180px;
}
/* style.css setzt h1 sehr gross (Website-Hero) - im Portal ruhiger */
.portal-main > h1 { font-size: 1.7rem; line-height: 1.25; margin-bottom: 0.3rem; color: #0f1117; }
.portal-main > h1 span { color: #1d6e80; }
.portal-section { display: none; }
.portal-section.active { display: block; }
.portal-section h1 { font-size: 1.5rem; margin-bottom: 0.4rem; }
.portal-section-sub { color: #666; font-size: 0.9rem; margin-bottom: 1.75rem; }
/* min(...) verhindert, dass die Spalte breiter wird als der Bildschirm */
.portal-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); gap: 12px; margin-bottom: 2rem; }
.portal-stat-card {
  background: #fff;
  border: 1px solid #e8ecf0;
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
}
.portal-stat-label { font-size: 0.78rem; color: #777; margin-bottom: 4px; }
.portal-stat-value { font-size: 1.5rem; font-weight: 500; }
.portal-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.portal-section-header h2 { font-size: 1.15rem; }

/* Kennzahl-Karte, die auf die passende Seite verlinkt */
a.portal-stat-card {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, transform 0.15s;
}
a.portal-stat-card:hover { border-color: #9cc9d1; transform: translateY(-1px); }
.portal-stat-card.is-alert { border-color: #f0a8a8; background: #fdf7f7; }
.portal-stat-card.is-alert .portal-stat-value { color: #a32d2d; }
.portal-stat-hint { font-size: 0.72rem; color: #999; margin-top: 4px; }

/* Aufgabenlisten auf der Uebersicht */
.portal-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr));
  gap: 1.25rem;
  align-items: start;
}
/* Lange Betreffs / E-Mail-Adressen duerfen die Karte nicht aufblasen */
.portal-panel .invoice-card > div:first-child { min-width: 0; }
.portal-panel .invoice-title,
.portal-panel .invoice-meta { overflow-wrap: anywhere; }
.portal-panel {
  background: #fff;
  border: 1px solid #e8ecf0;
  border-radius: 12px;
  padding: 1.1rem 1.25rem 1.25rem;
}
.portal-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 0.75rem;
}
.portal-panel-head h2 { font-size: 1rem; margin: 0; }
.portal-panel-head a { font-size: 0.8rem; color: #1d6e80; text-decoration: none; }
.portal-panel-head a:hover { text-decoration: underline; }
.portal-panel .invoice-card { background: #f7f9fc; margin-bottom: 0.5rem; }
.portal-panel .invoice-card:last-child { margin-bottom: 0; }
.portal-empty {
  font-size: 0.85rem;
  color: #8a9aa8;
  padding: 0.6rem 0;
}

/* Ausklappbares Formular - haelt Anlege-Masken aus dem Weg */
.portal-details {
  background: #fff;
  border: 1px solid #e8ecf0;
  border-radius: 12px;
  padding: 0 1.25rem;
  margin-bottom: 1.5rem;
}
.portal-details > summary {
  cursor: pointer;
  list-style: none;
  padding: 0.9rem 0;
  font-size: 0.92rem;
  font-weight: 500;
  color: #1d6e80;
  display: flex;
  align-items: center;
  gap: 8px;
}
.portal-details > summary::-webkit-details-marker { display: none; }
.portal-details > summary::after {
  content: '\002B';
  margin-left: auto;
  font-size: 1.1rem;
  color: #8fa8b4;
}
.portal-details[open] > summary { border-bottom: 1px solid #eef2f6; }
.portal-details[open] > summary::after { content: '\2212'; }
.portal-details > form { padding-bottom: 1.25rem; }

/* Such- und Filterleiste ueber den Tabellen */
.portal-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 1rem 0 0.25rem;
}
.portal-toolbar input[type="search"],
.portal-toolbar input[type="text"],
.portal-toolbar select {
  padding: 8px 12px;
  border: 1.5px solid #dde3eb;
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: inherit;
  background: #fff;
  color: #333;
}
.portal-toolbar input[type="search"] { flex: 1; min-width: 200px; }
.portal-toolbar select { min-width: 140px; }
.portal-toolbar .portal-toolbar-count {
  font-size: 0.8rem;
  color: #777;
  margin-left: auto;
  white-space: nowrap;
}

/* Sortierbare Tabellenkoepfe */
.admin-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.admin-table th.sortable:hover { color: #1d6e80; }
.admin-table th.sortable::after { content: '\2195'; opacity: 0.35; margin-left: 5px; }
.admin-table th.sort-asc::after { content: '\2191'; opacity: 1; color: #1d6e80; }
.admin-table th.sort-desc::after { content: '\2193'; opacity: 1; color: #1d6e80; }
.admin-table tr.row-alert td { background: #fdf7f7; }

@media (max-width: 768px) {
  .portal-page { flex-direction: column; }
  .portal-sidebar { width: 100%; flex-direction: row; align-items: center; overflow-x: auto; padding: 0.75rem; }
  .portal-user, .portal-copyright { display: none; }
  /* Logo bleibt als kleine Marke in der waagrechten Leiste */
  .portal-logo { margin: 0 0.5rem 0 0; flex-shrink: 0; }
  .portal-logo img { height: 40px; }
  .portal-nav { flex-direction: row; }
  .portal-nav-item { white-space: nowrap; width: auto; }
  /* Gruppentitel ergeben in der waagrechten Leiste keinen Sinn */
  .portal-nav-group { display: none; }
  .portal-nav-bottom { margin-top: 0; flex-direction: row; border-top: 0; padding-top: 0; }
  .portal-main { padding: 1.5rem; }
  .portal-stats { grid-template-columns: minmax(0, 1fr); }
  .portal-panels { grid-template-columns: minmax(0, 1fr); }
  /* Breite Tabellen scrollen in sich selbst statt die Seite zu verschieben */
  .admin-table { display: block; overflow-x: auto; white-space: nowrap; }
  .portal-toolbar .portal-toolbar-count { margin-left: 0; }
}
