/* Design-Tokens – abgestimmt auf die anderen DLRG-Tauberbischofsheim-Apps
   (Fahrtenbuch, Equipment, Reservierung, Protokoll) für ein einheitliches CI. */
:root {
  --dlrg-red: #e2001a;
  --dlrg-red-dark: #b8001a;
  --dlrg-red-light: #fef2f2;
  --dlrg-yellow: #f9b000;
  --canvas: #f9fafb;
  --surface: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 10px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 10px 24px rgba(16, 24, 40, 0.12);
  --focus-ring: 0 0 0 2px rgba(226, 0, 26, 0.35);

  --ok: #15803d;
  --ok-bg: #ecfdf3;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --neutral: #6b7280;
  --neutral-bg: #f3f4f6;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  line-height: 1.5;
}

a { color: var(--dlrg-red); }

/* ---------- Kopfbalken ---------- */

header.top {
  background: var(--dlrg-red);
  color: #fff;
  height: 56px;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: nowrap;
  position: sticky;
  top: 0;
  z-index: 30;
}

header.top a { color: #fff; text-decoration: none; }

header.top .brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}
header.top .brand img {
  height: 34px;
  width: auto;
  background: #fff;
  border-radius: 6px;
  padding: 2px 5px;
  flex-shrink: 0;
}
header.top .brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}
header.top .brand-text .brand-title {
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
}
header.top .brand-text .brand-sub {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.85);
  white-space: nowrap;
}

header.top .spacer { flex: 1 1 auto; }

header.top form.inline {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}
header.top form.inline span {
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}
header.top .btn.secondary {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
}
header.top .btn.secondary:hover { background: rgba(255, 255, 255, 0.28); }

/* ---------- Layout & Sidebar ---------- */

.layout {
  display: flex;
  align-items: stretch;
  min-height: calc(100vh - 56px);
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  width: 240px;
  flex: 0 0 240px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.side-nav {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.75rem 0.75rem 0.75rem 0;
  overflow-y: auto;
}

.side-nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.7rem 0.75rem 0.7rem 1rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  border-left: 4px solid transparent;
  transition: background 0.12s ease, color 0.12s ease;
}

.side-nav a svg { flex-shrink: 0; color: #9ca3af; }

.side-nav a:hover { background: var(--neutral-bg); color: var(--ink); }
.side-nav a:hover svg { color: var(--muted); }

.side-nav a.active {
  background: var(--dlrg-red-light);
  color: var(--dlrg-red);
  border-left-color: var(--dlrg-red);
  padding-left: calc(1rem - 4px);
  font-weight: 700;
}
.side-nav a.active svg { color: var(--dlrg-red); }

.side-nav-section {
  margin-top: 1rem;
  margin-bottom: 0.15rem;
  padding: 0 0.75rem 0 1rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9ca3af;
}
.side-nav-section.with-rule {
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
  margin-top: 1.1rem;
}

.side-user {
  border-top: 1px solid var(--border);
  background: var(--canvas);
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.side-user .avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--dlrg-red);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.side-user .who { min-width: 0; }
.side-user .who .name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-user .who .role {
  font-size: 0.75rem;
  color: var(--muted);
}

main {
  padding: 1.75rem 2.25rem;
  max-width: 1680px;
  width: 100%;
  margin: 0 auto;
  flex: 1 1 auto;
  min-width: 0;
}

@media (max-width: 800px) {
  .layout { display: block; min-height: 0; }
  header.top { position: static; }
  .sidebar {
    width: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .side-nav { flex-direction: row; flex-wrap: wrap; padding: 0.6rem; }
  .side-nav a { border-left: none; border-radius: var(--radius); padding: 0.5rem 0.7rem; }
  .side-nav a.active { padding-left: 0.7rem; border-left: none; }
  .side-nav-section { display: none; }
  .side-user { display: none; }
  main { padding: 1.25rem; }
}

/* ---------- Überschriften ---------- */

h1, h2, h3 { color: var(--ink); font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; margin: 0 0 0.3rem; }
h2 { font-size: 1.15rem; }

/* ---------- Tabellen ---------- */

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-bottom: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

th, td {
  padding: 0.7rem 0.85rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--canvas);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafafa; }

.actions-cell {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.table-scroll {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
}
.table-scroll table { margin-bottom: 0; }

/* Kostenpunkt-Tabellen: über alle Bereiche hinweg gleiche Spaltenbreiten,
   gleiche Zeilenhöhe und vertikal zentrierter Inhalt je Zeile. */
.posten-table {
  table-layout: fixed;
  min-width: 58rem;
}
.posten-table .col-reihenfolge { width: 5.5rem; }
.posten-table th:first-child,
.posten-table td:first-child {
  padding-right: 1.1rem;
}
.posten-table .col-leistung { width: 44%; }
.posten-table .col-einheit { width: 9%; }
.posten-table .col-mitglieder { width: 10%; }
.posten-table .col-nichtmitglieder { width: 12%; }
.posten-table .col-status { width: 8rem; }
.posten-table .col-aktionen { width: 17rem; }

.posten-table td {
  vertical-align: middle;
  min-height: 3.25rem;
}
.posten-table td:first-of-type { padding-top: 0.5rem; padding-bottom: 0.5rem; }

/* Kopfzeilen dürfen bei Bedarf sauber in eine zweite Zeile umbrechen,
   statt in die Nachbarspalte zu laufen. */
.posten-table th {
  overflow-wrap: break-word;
  word-break: break-word;
  white-space: normal;
}

/* Beträge: rechtsbündig wie in Finanztabellen üblich, nie umbrechen. */
.posten-table td.col-betrag-wert {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.posten-table th.col-betrag-head { text-align: right; }

/* Status-Spalte optisch zentrieren. */
.posten-table td.col-status-wert,
.posten-table th.col-status-head {
  text-align: center;
}

/* ---------- Status-Badges ---------- */

.status {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}
.status-entwurf { background: var(--neutral-bg); color: var(--neutral); }
.status-eingereicht { background: var(--warn-bg); color: var(--warn); }
.status-freigegeben { background: var(--ok-bg); color: var(--ok); }
.status-zurueckgewiesen { background: var(--dlrg-red-light); color: var(--dlrg-red-dark); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  white-space: nowrap;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--dlrg-red);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  transition: background 0.12s ease, transform 0.05s ease;
}
.btn:hover { background: var(--dlrg-red-dark); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--border); }
.btn.secondary:hover { background: var(--neutral-bg); }
.btn.small { padding: 0.3rem 0.65rem; font-size: 0.8rem; }
.btn.danger { background: #fff; color: var(--dlrg-red-dark); border-color: #fecaca; }
.btn.danger:hover { background: var(--dlrg-red-light); }
.btn.ok { background: var(--ok); }
.btn.ok:hover { background: #116932; }
.btn.warn { background: #fff; color: var(--warn); border-color: #fde68a; }
.btn.warn:hover { background: var(--warn-bg); }

form.inline { display: inline; }

/* ---------- Karten ---------- */

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.5rem;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

/* ---------- Hinweise ---------- */

.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--dlrg-red-dark);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.92rem;
}

.hinweis {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92620a;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.92rem;
}

/* ---------- Formulare ---------- */

label { display: block; margin-top: 0.9rem; margin-bottom: 0.2rem; font-weight: 600; font-size: 0.88rem; color: var(--ink); }
input[type=text], input[type=number], input[type=password], input[type=date], select, textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--dlrg-red);
  box-shadow: var(--focus-ring);
}
textarea { min-height: 5.5rem; resize: vertical; }

/* ---------- Login ---------- */

body.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-wrap { width: 100%; max-width: 380px; margin: 0 auto; }

.login-header { text-align: center; margin-bottom: 1.5rem; }
.login-header .login-logo {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 50%;
  background: var(--dlrg-red);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}
.login-header h1 {
  font-size: 1.4rem;
  margin-bottom: 0.15rem;
}
.login-header p { color: var(--muted); margin: 0; }

.login-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  padding: 1.75rem 1.75rem 1.5rem;
}

.login-footer {
  text-align: center;
  color: #9ca3af;
  font-size: 0.75rem;
  margin-top: 1.5rem;
}

/* ---------- Bereichs-Blöcke ---------- */

.bereich-block { margin-bottom: 1.5rem; }
.bereich-block h2 {
  border-bottom: 3px solid var(--dlrg-yellow);
  padding-bottom: 0.4rem;
  display: inline-block;
}

.kommentar {
  font-style: italic;
  color: var(--dlrg-red-dark);
  font-size: 0.88rem;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.1rem;
}

/* ---------- Kennzahlen-Übersicht ---------- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.9rem 1.1rem;
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-value { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.stat-card .stat-label { font-size: 0.8rem; color: var(--muted); margin-top: 0.15rem; }
.stat-card.accent-entwurf .stat-value { color: var(--neutral); }
.stat-card.accent-eingereicht .stat-value { color: var(--warn); }
.stat-card.accent-freigegeben .stat-value { color: var(--ok); }
.stat-card.accent-zurueckgewiesen .stat-value { color: var(--dlrg-red-dark); }

.empty-state {
  color: var(--muted);
  font-size: 0.92rem;
  padding: 0.5rem 0;
}

@media print {
  header.top, .no-print { display: none !important; }
  main { max-width: none; padding: 0; }
  body { font-size: 11pt; background: #fff; }
}
