:root{
  --bg:#0b0f14;
  --card:#0f1620;
  --card2:#111a25;
  --text:#e8eef7;
  --muted:#9fb0c6;
  --line:rgba(255,255,255,.08);
  --accent:#ff3b30; /* Feuerwehr-Rot */
  --accent2:#ff9500; /* Orange */
  --ok:#28c76f;
  --warn:#ffcc00;
  --bad:#ff453a;
  --shadow: 0 14px 50px rgba(0,0,0,.45);
  --radius: 18px;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  /* Einfarbiger Hintergrund */
  background-color: var(--bg);
  color:var(--text);
  font: 15px/1.4 system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

a{color:inherit}
code{background:rgba(255,255,255,.06); padding:.15rem .35rem; border-radius:8px; border:1px solid var(--line);}

.topbar{
  position:sticky; top:0; z-index:5;
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 22px;
  backdrop-filter: blur(10px);
  background: rgba(11,15,20,.65);
  border-bottom: 1px solid var(--line);
}

.brand{display:flex; gap:12px; align-items:center}
.brand-title{font-weight:800; letter-spacing:.2px}
.brand-sub{color:var(--muted); font-size:12px}

.flame{
  width:34px; height:34px;
  border-radius:12px;
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,.35), transparent 35%),
    radial-gradient(circle at 40% 70%, rgba(255,149,0,.9), transparent 55%),
    radial-gradient(circle at 65% 40%, rgba(255,59,48,.9), transparent 60%),
    linear-gradient(135deg, rgba(255,59,48,.85), rgba(255,149,0,.85));
  box-shadow: 0 10px 30px rgba(255,59,48,.18);
}

.nav{display:flex; gap:10px; flex-wrap:wrap}
.navlink{
  text-decoration:none;
  padding:8px 12px;
  border:1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.03);
}
.navlink:hover{border-color: rgba(255,255,255,.18)}

.container{max-width:1200px; margin:18px auto; padding:0 18px 40px}

.card{
  background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.01));
  border:1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}

.card-head{
  display:flex; align-items:flex-start; justify-content:space-between;
  gap:14px;
  margin-bottom: 10px;
}
h1,h2{margin:0}
h1{font-size:22px}
h2{font-size:18px}
.sub{color:var(--muted); font-size:13px; margin-top:4px}
.muted{color:var(--muted)}
.strong{font-weight:700}
.right{text-align:right}
.row{display:flex; gap:8px; align-items:center}

.divider{height:1px; background:var(--line); margin:14px 0}

.grid{display:grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap:12px; align-items:end}
.grid2{display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap:16px}
.grid3{display:grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap:12px}

@media (max-width: 980px){
  .grid{grid-template-columns: repeat(2, minmax(0,1fr));}
  .grid2{grid-template-columns: 1fr;}
  .grid3{grid-template-columns: 1fr;}
  .nav{justify-content:flex-end}
}

label{display:block; font-size:12px; color:var(--muted); margin-bottom:6px}
.input,.select,.textarea{
  width:100%;
  padding:10px 12px;
  border-radius: 14px;
  border:1px solid var(--line);
  background: rgba(255,255,255,.08); /* Heller Hintergrund für bessere Lesbarkeit */
  color: #ffffff; /* Hellere Schrift */
  outline:none;
}
.input:focus,.select:focus,.textarea:focus{border-color: rgba(255,149,0,.55); box-shadow: 0 0 0 4px rgba(255,149,0,.10);}

/* Dropdown-Optionen: schwarze Schrift auf hellem Hintergrund */
.select option {
  background: #f5f5f5;
  color: #000000;
}

/* Kleineres Input-Feld für Dauer */
.input-small {
  padding: 6px 8px;
  font-size: 14px;
}

/* Duration Form Styling */
.duration-form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.duration-label {
  color: var(--text);
  font-size: 14px;
}

.pre{
  white-space:pre-wrap;
  background: rgba(0,0,0,.25);
  border:1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}

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

.btn{
  border:1px solid var(--line);
  border-radius: 14px;
  padding:10px 12px;
  background: rgba(255,255,255,.03);
  color:var(--text);
  cursor:pointer;
  text-decoration:none;
  font-weight:650;
}
.btn:hover{border-color: rgba(255,255,255,.20)}
.btn-small{padding:7px 10px; border-radius: 12px; font-size:13px}
.btn-primary{
  border-color: rgba(255,59,48,.55);
  background: linear-gradient(135deg, rgba(255,59,48,.65), rgba(255,149,0,.35));
}
.btn-danger{
  border-color: rgba(255,69,58,.55);
  background: rgba(255,69,58,.12);
}
.btn-ghost{
  background: transparent;
}
.footer{
  color: rgba(255,255,255,.45);
  font-size: 12px;
  padding: 14px 22px 20px;
  text-align:center;
}

.table{display:flex; flex-direction:column; gap:8px; margin-top:10px}
.tr{
  display:grid;
  grid-template-columns: 2fr 1fr 1.5fr 1fr; /* Name, Typ, Kategorie, Aktionen */
  gap:10px;
  align-items:center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.02);
}
.tr.th{
  background: rgba(255,255,255,.04);
  font-size:12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}
@media (max-width: 980px){
  .tr{grid-template-columns: 1fr; gap:6px}
  .right{text-align:left}
}

.tag{
  display:inline-flex;
  align-items:center;
  padding: 4px 10px;
  border-radius: 999px;
  border:1px solid var(--line);
  background: rgba(255,255,255,.02);
  font-size: 12px;
  color: var(--text);

  /* Default: möglichst kompakt, aber nicht überlaufen lassen */
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== TERMINE-TABELLE (Config-Seite, zweite Card) ===== */

/* Basis-Layout: 2 Reihen mit 3 Spalten in der zweiten Reihe */
.grid2 > section.card:nth-child(2) .table .tr {
  display: grid;
  grid-template-columns: 1fr 1.5fr 1fr; /* Typ, Kategorie, Aktionen */
  grid-template-rows: auto auto; /* Zwei Reihen */
  gap: 8px 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.02);
}

.grid2 > section.card:nth-child(2) .table .tr.th {
  background: rgba(255,255,255,.04);
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  grid-template-rows: auto; /* Header bleibt einzeilig */
}

/* Name: Erste Reihe, über alle Spalten */
.grid2 > section.card:nth-child(2) .table .tr > div:nth-child(1) {
  grid-column: 1 / 4;
  grid-row: 1;
  font-size: 15px;
  font-weight: 700;
}

/* Typ: Zweite Reihe, erste Spalte */
.grid2 > section.card:nth-child(2) .table .tr > div:nth-child(2) {
  grid-column: 1;
  grid-row: 2;
}

/* Kategorie: Zweite Reihe, zweite Spalte */
.grid2 > section.card:nth-child(2) .table .tr > div:nth-child(3) {
  grid-column: 2;
  grid-row: 2;
}

/* Aktionen: Zweite Reihe, dritte Spalte */
.grid2 > section.card:nth-child(2) .table .tr > div:nth-child(4) {
  grid-column: 3;
  grid-row: 2;
  justify-self: end;
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Header: alle Spalten in einer Reihe */
.grid2 > section.card:nth-child(2) .table .tr.th > div:nth-child(1) {
  grid-column: 1;
  grid-row: 1;
}

.grid2 > section.card:nth-child(2) .table .tr.th > div:nth-child(2) {
  grid-column: 2;
  grid-row: 1;
}

.grid2 > section.card:nth-child(2) .table .tr.th > div:nth-child(3) {
  grid-column: 3;
  grid-row: 1;
}

.grid2 > section.card:nth-child(2) .table .tr.th > div:nth-child(4) {
  grid-column: 4;
  grid-row: 1;
  justify-self: end;
}

/* Kategorie-Tag: kompakt halten */
.grid2 > section.card:nth-child(2) .table .tr > div:nth-child(3) .tag {
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Aktionen-Spalte: Buttons rechtsbündig */
.grid2 > section.card:nth-child(2) .table .tr > div:nth-child(4) {
  justify-self: end;
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Move-Button Styling */
.grid2 > section.card:nth-child(2) .table .tr .move-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.02);
  color: var(--muted);
  border-radius: 10px;
  padding: 6px 8px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
}

.grid2 > section.card:nth-child(2) .table .tr .move-btn:active {
  cursor: grabbing;
  color: var(--text);
  background: rgba(255,149,0,.08);
}

/* Mobile: Stack */
@media (max-width: 768px) {
  .grid2 > section.card:nth-child(2) .table .tr {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto; /* 4 Reihen für mobile */
    gap: 6px;
  }
  
  .grid2 > section.card:nth-child(2) .table .tr > div:nth-child(1),
  .grid2 > section.card:nth-child(2) .table .tr > div:nth-child(2),
  .grid2 > section.card:nth-child(2) .table .tr > div:nth-child(3),
  .grid2 > section.card:nth-child(2) .table .tr > div:nth-child(4) {
    grid-column: 1;
    grid-row: auto;
  }
  
  .grid2 > section.card:nth-child(2) .table .tr > div:nth-child(4) {
    justify-self: start;
  }
}
.drag-ghost {
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,.45);
  background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.01));
  opacity: .98;
  overflow: hidden;
}

/* Placeholder (Einfügeposition) */
.drag-placeholder {
  border: 2px dashed rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.01);
  border-radius: 12px;
  box-sizing: border-box;
}

/* Prevent accidental pointer cursor on whole row */
.grid2 > section.card:nth-child(2) .table .tr:not(.th) {
  cursor: default;
}

/* Setze das Dropdown für Übungen normal nach links */
.grid > div:first-child {
  grid-column: 1 / 3;
}

/* ===== ANALYSIS-TABELLE ===== */

.analysis-table .tr {
  grid-template-columns: 2fr 1.5fr 1.5fr; /* Name, Gruppe, Stats */
}

.analysis-table .stats-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.analysis-table .stat-item {
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 14px;
}

.analysis-table .stat-present {
  color: var(--ok);
  background: rgba(40, 199, 111, 0.1);
}

.analysis-table .stat-excused {
  color: var(--warn);
  background: rgba(255, 204, 0, 0.1);
}

.analysis-table .stat-absent {
  color: var(--bad);
  background: rgba(255, 69, 58, 0.1);
}

.analysis-table .stat-separator {
  color: var(--muted);
  font-weight: 400;
}

@media (max-width: 768px) {
  .analysis-table .tr {
    grid-template-columns: 1fr;
  }
  
  .analysis-table .stats-row {
    justify-content: flex-start;
  }
}

/* ===== EVENT STATUS TAGS ===== */

.status-tag {
  font-weight: 600;
  border: none;
}

.status-present {
  color: var(--ok);
  background: rgba(40, 199, 111, 0.15);
}

.status-excused {
  color: var(--warn);
  background: rgba(255, 204, 0, 0.15);
}

.status-absent {
  color: var(--bad);
  background: rgba(255, 69, 58, 0.15);
}

/* ===== EVENT STATUS BUTTONS ===== */

.status-buttons {
  display: flex;
  gap: 6px;
  align-items: center;
}

.btn-status {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 10px;
  white-space: nowrap;
}

.btn-status.status-present {
  border-color: rgba(40, 199, 111, 0.3);
  background: rgba(40, 199, 111, 0.08);
  color: var(--ok);
}

.btn-status.status-present:hover {
  background: rgba(40, 199, 111, 0.15);
  border-color: rgba(40, 199, 111, 0.5);
}

.btn-status.status-excused {
  border-color: rgba(255, 204, 0, 0.3);
  background: rgba(255, 204, 0, 0.08);
  color: var(--warn);
}

.btn-status.status-excused:hover {
  background: rgba(255, 204, 0, 0.15);
  border-color: rgba(255, 204, 0, 0.5);
}

.btn-status.status-absent {
  border-color: rgba(255, 69, 58, 0.3);
  background: rgba(255, 69, 58, 0.08);
  color: var(--bad);
}

.btn-status.status-absent:hover {
  background: rgba(255, 69, 58, 0.15);
  border-color: rgba(255, 69, 58, 0.5);
}

@media (max-width: 768px) {
  .status-buttons {
    flex-direction: column;
    gap: 4px;
    align-items: stretch;
  }
  
  .btn-status {
    width: 100%;
  }
}

/* ===== FORM SPACING ===== */

/* Abstand zwischen Form-Elementen */
.form > div,
.form > .grid2,
.form > .divider,
.form > label,
.form > p {
  margin-bottom: 12px;
}

/* Abstand zwischen Input/Select und nachfolgenden Elementen */
.form .input,
.form .select,
.form .textarea {
  margin-bottom: 0;
}

/* Buttons innerhalb von Forms haben Abstand nach oben */
.form .btn,
.form button[type="submit"] {
  margin-top: 14px;
}

/* Spezielle Regel für Import-Forms: File-Input und Button in einer Reihe */
.form.import-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form.import-form > div {
  display: flex;
  gap: 10px;
  align-items: end;
}

.form.import-form input[type="file"] {
  flex: 1;
}

.form.import-form .btn {
  margin-top: 0;
  white-space: nowrap;
}

/* CSV Import Container */
.csv-import-container {
  display: flex;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}

.csv-import-container input[type="file"] {
  flex: 1;
}

.csv-import-container .btn {
  margin-top: 0;
}

/* ===== LOGIN PAGE ===== */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: 
    radial-gradient(circle at 20% 80%, rgba(255, 59, 48, 0.05), transparent 40%),
    radial-gradient(circle at 80% 20%, rgba(255, 149, 0, 0.05), transparent 40%),
    var(--bg);
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 20px;
}

.login-card {
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 
    var(--shadow),
    0 0 0 1px rgba(255,255,255,.02) inset;
  padding: 40px 32px;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-header .flame {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
}

.login-header h1 {
  font-size: 24px;
  font-weight: 800;
  margin: 0 0 8px 0;
  background: linear-gradient(135deg, var(--text), var(--muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-subtitle {
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}

.login-error {
  background: rgba(255, 69, 58, 0.12);
  border: 1px solid rgba(255, 69, 58, 0.3);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 24px;
  color: var(--bad);
  font-size: 14px;
}

.login-error strong {
  font-weight: 700;
}

.login-form {
  margin-bottom: 24px;
}

.login-form > div {
  margin-bottom: 20px;
}

.captcha-container {
  margin-bottom: 20px;
}

.captcha-question {
  background: rgba(255,149,0,.08);
  border: 1px solid rgba(255,149,0,.2);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 10px;
  text-align: center;
}

.captcha-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent2);
  font-family: monospace;
  letter-spacing: 0.5px;
}

.captcha-input {
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 2px;
}

.login-form label {
  display: block;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 8px;
  font-weight: 600;
}

.login-form .input {
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.05);
  color: var(--text);
  transition: all 0.2s ease;
}

.login-form .input:focus {
  border-color: rgba(255,149,0,.6);
  box-shadow: 0 0 0 4px rgba(255,149,0,.12);
  background: rgba(255,255,255,.08);
}

.login-form .input::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.btn-login {
  width: 100%;
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, rgba(255,59,48,.75), rgba(255,149,0,.45));
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-login:hover {
  background: linear-gradient(135deg, rgba(255,59,48,.85), rgba(255,149,0,.55));
  box-shadow: 0 8px 20px rgba(255,59,48,.25);
  transform: translateY(-1px);
}

.btn-login:active {
  transform: translateY(0);
}

.login-footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

@media (max-width: 480px) {
  .login-card {
    padding: 32px 24px;
  }
  
  .login-header h1 {
    font-size: 20px;
  }
}
