:root {
  --bg: #020617;
  --fg: #e5e7eb;
  --panel-bg: #020617;
  --panel-border: #1f2937;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --muted: #9ca3af;
  --nav-bg: #020617;
  --input-bg: #020617;
  --input-border: #374151;
  --table-header-bg: #111827;
  --table-border: #1f2937;
  --error-bg: #450a0a;
  --error-fg: #fecaca;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  background: var(--bg);
  color: var(--fg);
  line-height: 1.4;
  font-size: 17px;
}

/* --- Topbar / Nav --- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--nav-bg);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.6);
}

.brand {
  font-weight: 600;
  font-size: 1.25rem;
}

.nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-link {
  color: #f9fafb;
  text-decoration: none;
  font-size: 0.98rem;
  padding: 5px 12px;
  border-radius: 6px;
}

.nav-link:hover { background: #374151; }

.nav-link.active {
  background: var(--accent);
  color: #ffffff;
}

/* Logout-Button */

.nav-button {
  border: none;
  cursor: pointer;
  background: #dc2626;
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 0.98rem;
  font-weight: 500;
}

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

button,
.btn,
.nav-button,
.tab-button {
  color: #ffffff !important;
}

button:disabled,
.btn:disabled,
.nav-button:disabled,
.tab-button:disabled {
  color: #e5e7eb !important;
  opacity: 0.7;
}

.btn {
  border-radius: 6px;
  border: none;
  background: var(--accent);
  padding: 8px 12px;
  font-size: 0.98rem;
  cursor: pointer;
  font-weight: 500;
}

.btn:hover { background: var(--accent-hover); }

.btn.small {
  padding: 6px 10px;
  font-size: 0.9rem;
}

.btn.secondary { background: #6b7280; }
.btn.secondary:hover { background: #4b5563; }

.btn.full { width: 100%; }

.nav-button:hover { background: #b91c1c; }

/* --- Layout / Panels --- */

.main {
  max-width: 1200px;
  margin: 20px auto 32px auto;
  padding: 0 12px;
}

.panel {
  background: var(--panel-bg);
  border-radius: 12px;
  padding: 20px 20px 22px;
  margin-bottom: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.45);
  border: 1px solid var(--panel-border);
  color: #f9fafb;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 1.3rem;
}

/* --- Formulare --- */

.form-row {
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.form-row-inline {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

label {
  font-size: 0.85rem;
  color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"],
select {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--input-border);
  font-size: 0.98rem;
  min-width: 0;
  background: var(--input-bg);
  color: #f9fafb;
}

input::placeholder { color: #6b7280; }

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(37,99,235,0.45);
}

.hint {
  font-size: 0.82rem;
  color: var(--muted);
}

.error-msg {
  font-size: 0.85rem;
  color: var(--error-fg);
  background: var(--error-bg);
  border-radius: 6px;
  padding: 4px 6px;
}

/* --- Atemschutz / Trupps --- */

.trupp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(540px, 1fr)); /* 2 Karten nebeneinander auf breiten Screens */
  gap: 18px;
  align-items: stretch;
}

.trupp-card {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 16px 18px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: #020617;
  color: #f9fafb;
}

.trupp-card.alert {
  animation: blink 1s linear infinite;
  border-color: #b91c1c;
}

@keyframes blink {
  0%, 50%, 100% { box-shadow: 0 0 0 rgba(220,38,38,0); }
  25%, 75% { box-shadow: 0 0 14px rgba(220,38,38,0.85); }
}

.trupp-left { flex: 2; min-width: 0; }

.trupp-right {
  flex: 0 0 170px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.trupp-name {
  font-weight: 700;
  margin-bottom: 4px;
  font-size: 1.35rem;
  color: #ffffff;
}

.small {
  font-size: 0.98rem;
  color: var(--muted);
}

/* --- Druck-Eingabezeile: Felder = Boxbreite, Button ganz rechts --- */

.press-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto; /* Person 1 | Person 2 | Button */
  column-gap: 10px;
  align-items: center;
  margin-top: 12px;
  width: 100%;
}

.press-input {
  width: 100%;
}

.press-input input {
  width: 100%;
}

/* Button sitzt in Spalte 3, bleibt in derselben Zeile */
.press-row .btn {
  grid-column: 3;
}

/* --- Personen-Boxen: exakt gleiche Spalten wie oben --- */

.person-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto; /* Box1 | Box2 | Dummy */
  column-gap: 10px;
  margin-top: 12px;
  width: 100%;
}

/* Boxen links und mittig */
.person-box:nth-child(1) { grid-column: 1; }
.person-box:nth-child(2) { grid-column: 2; }

/* Unsichtbare dritte Spalte mit gleicher Breite wie Button */
.person-grid::after {
  content: "";
  grid-column: 3;
}

.person-box {
  border-radius: 8px;
  background: #020617;
  border: 1px solid var(--panel-border);
  padding: 10px;
  font-size: 0.95rem;
  color: #ffffff;
}

.person-name {
  font-weight: 700;
  margin-bottom: 4px;
  color: #ffffff;
  font-size: 1.02rem;
}

.person-pressure {
  font-size: 1.1rem;
  margin-bottom: 3px;
  color: #ffffff;
}

.person-eta {
  font-size: 0.95rem;
  color: #e5e7eb;
}

.muted { color: var(--muted); }

.since-warning {
  color: #fbbf24;
  font-weight: 700;
}

/* --- Login --- */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #1f2937 0, #020617 55%, #000 100%);
}

.login-wrapper {
  width: 100%;
  max-width: 380px;
  padding: 16px;
}

.login-box {
  background: #020617;
  color: #e5e7eb;
  border-radius: 12px;
  padding: 22px 20px 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
  border: 1px solid #1f2937;
}

.login-box h1 {
  margin-top: 0;
  margin-bottom: 4px;
  font-size: 1.4rem;
}

.login-subtitle {
  margin: 0 0 16px;
  font-size: 0.82rem;
  color: #9ca3af;
}

.login-box .form-row label { color: #d1d5db; }

.login-box input {
  background: #020617;
  color: #f9fafb;
  border-color: #4b5563;
}

.login-box input:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 1px #60a5fa33;
}

/* --- Modal --- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal.show { display: flex; }

.modal-dialog {
  background: var(--panel-bg);
  color: #f9fafb;
  border-radius: 10px;
  padding: 16px 18px;
  max-width: 520px;
  width: 100%;
  box-shadow: 0 10px 25px rgba(0,0,0,0.6);
  border: 1px solid var(--panel-border);
}

.modal-dialog h3 {
  margin-top: 0;
  margin-bottom: 6px;
  font-size: 1.08rem;
}

.modal-dialog h4 {
  margin-top: 12px;
  margin-bottom: 4px;
  font-size: 0.9rem;
  color: var(--muted);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

/* --- Admin-Bereich allgemein --- */

.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.tab-button {
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: #111827;
  padding: 7px 12px;
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 500;
}

.tab-button.active {
  background: var(--accent);
  border-color: var(--accent);
}

.admin-section { display: none; }
.admin-section.active { display: block; }

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.inline-form input,
.inline-form select {
  min-width: 140px;
}

/* Tabellen */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  color: #f9fafb;
}

.table th,
.table td {
  border: 1px solid var(--table-border);
  padding: 4px 6px;
  text-align: left;
}

.table th {
  background: var(--table-header-bg);
  font-weight: 600;
}

/* AGT-Gruppen */

.agt-group-block { margin-top: 12px; }

.agt-group-block h3 {
  margin: 0 0 4px;
  font-size: 0.98rem;
}

.agt-group-block table { table-layout: fixed; }

.agt-group-block table th:nth-child(1),
.agt-group-block table td:nth-child(1) { width: 18%; }
.agt-group-block table th:nth-child(2),
.agt-group-block table td:nth-child(2) { width: 18%; }
.agt-group-block table th:nth-child(3),
.agt-group-block table td:nth-child(3) { width: 18%; }
.agt-group-block table th:nth-child(4),
.agt-group-block table td:nth-child(4) { width: 18%; }
.agt-group-block table th:nth-child(5),
.agt-group-block table td:nth-child(5) { width: 18%; }
.agt-group-block table th:nth-child(6),
.agt-group-block table td:nth-child(6) { width: 10%; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #ffffff;
}

.status-badge-icon { font-size: 0.8rem; }

.status-ok   { background: #14532d; }
.status-warn { background: #78350f; }
.status-bad  { background: #7f1d1d; }

tr.agt-warn td { background: rgba(245, 158, 11, 0.08); }
tr.agt-bad  td { background: rgba(220, 38, 38, 0.12); }

/* --- AGT-Modal: Felder untereinander und gleich breit --- */

#agtModal .form-row-inline {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

#agtModal .form-row-inline > div {
  width: 100%;
}

#agtModal input,
#agtModal select {
  width: 100%;
  box-sizing: border-box;
}

/* --- Responsive --- */

@media (max-width: 900px) {
  .trupp-grid { grid-template-columns: minmax(0, 1fr); }
  .trupp-right { flex: 0 0 150px; }
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .nav { justify-content: flex-start; }
}
