@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #f2f4f7;
  --surface:    #ffffff;
  --border:     #dde1e8;
  --border-lt:  #edf0f4;

  --text:       #1a2b40;
  --text-2:     #5c6b7e;
  --text-3:     #8996a6;

  --primary:    #c0392b;   /* Gymrut-Rot — Buttons, Akzente */
  --primary-h:  #a02d22;
  --primary-lt: #fdf0ee;

  --green:      #2a7a46;   /* Km-Werte, Erfolg */
  --green-lt:   #e8f4ed;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 3px solid var(--primary);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 24px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.logo img {
  height: 32px;
  width: auto;
  display: block;
}
.header-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: .3px;
  border-left: 1px solid var(--border);
  padding-left: 16px;
  margin-left: 4px;
}
.logo-group {
  display: flex;
  align-items: center;
  gap: 0;
}
nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-info {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}
.btn-nav {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  transition: background .12s, color .12s;
}
.btn-nav:hover { background: var(--bg); color: var(--text); text-decoration: none; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
  padding: 11px 16px;
  border-radius: 4px;
  font-size: 13.5px;
  margin-bottom: 16px;
  border-left: 3px solid;
}
.alert-error   { background: #fef2f2; border-color: #ef4444; color: #991b1b; }
.alert-success { background: #f0fdf4; border-color: #22c55e; color: #15643a; }
.alert-warning { background: #fffbeb; border-color: #f59e0b; color: #92520a; }

/* ── Page Header ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.page-header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.total-km {
  font-size: 20px;
  font-weight: 700;
  color: var(--green);
}
.campaign-info {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 16px;
}
h2 {
  font-size: 13.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-3);
  margin-bottom: 14px;
}

/* ── Panels ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px 22px;
  margin-bottom: 16px;
}

/* ── Login Card ──────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: calc(100vh - 58px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
  background: var(--bg);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 36px 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
}
.login-card .login-logo {
  text-align: center;
  margin-bottom: 8px;
}
.login-card .login-logo img {
  height: 38px;
  width: auto;
}
.login-card .login-subtitle {
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-lt);
}

/* ── Forms ───────────────────────────────────────────────────────────────── */
label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 14px;
}
label span {
  display: block;
  margin-bottom: 5px;
}
label input,
label select {
  display: block;
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color .12s, box-shadow .12s;
}
label input:focus,
label select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(42,122,70,.12);
}
label select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238996a6' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.form-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 12px;
}
.form-row label { flex: 1; min-width: 160px; margin-bottom: 0; }

.form-inline {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}
.form-inline input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
}
.form-inline input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(42,122,70,.12);
}
.form-inline-small {
  display: flex;
  gap: 6px;
  align-items: center;
}
.form-inline-small input {
  width: 90px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
}
.inline-form { display: inline; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary, .btn-secondary, .btn-small, .btn-full, button[type=submit] {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s;
  white-space: nowrap;
}
button[type=submit], .btn-primary {
  background: var(--primary);
  color: #fff;
}
button[type=submit]:hover, .btn-primary:hover { background: var(--primary-h); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg); color: var(--text); text-decoration: none; }

.btn-small {
  padding: 5px 12px;
  font-size: 12px;
  background: var(--primary-lt);
  color: var(--primary);
  border: 1px solid #c3dfc9;
}
.btn-small:hover { background: #d4ebd9; }
.btn-small.btn-warn { background: #fff3cd; color: #856404; border-color: #e6d48a; }
.btn-small.btn-warn:hover { background: #ffe69c; }

.btn-full { width: 100%; justify-content: center; }

.btn-delete {
  background: none;
  border: none;
  color: #b91c1c;
  font-size: 12.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 3px;
  transition: background .12s;
}
.btn-delete:hover { background: #fef2f2; }

.admin-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 380px;
}
th {
  text-align: left;
  padding: 9px 14px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-3);
  background: #f8f9fb;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-lt);
  color: var(--text);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8f9fb; }

/* ── Student List ────────────────────────────────────────────────────────── */
.student-list { list-style: none; }
.student-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-lt);
  font-size: 13.5px;
}
.student-list li:last-child { border-bottom: none; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge-active   { background: #dcfce7; color: #15803d; padding: 2px 8px; border-radius: 3px; font-size: 12px; font-weight: 600; }
.badge-inactive { background: var(--border-lt); color: var(--text-3); padding: 2px 8px; border-radius: 3px; font-size: 12px; font-weight: 600; }
code { background: var(--primary-lt); color: var(--primary); padding: 2px 7px; border-radius: 3px; font-size: 13px; }
.code-display { font-size: 14px; font-weight: 700; letter-spacing: .08em; }

/* ── Misc ────────────────────────────────────────────────────────────────── */
.muted { color: var(--text-3); font-style: italic; font-size: 13px; }
.hint  { font-size: 12px; color: var(--text-3); margin-top: 10px; }

/* ── Preview-Aktionsleiste ───────────────────────────────────────────────── */
.preview-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}
.preview-actions-left,
.preview-actions-right { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  main { padding: 20px 16px 40px; }
  .header-inner { padding: 0 16px; }
  .header-title { display: none; }
  .login-card { padding: 28px 20px; }
  .form-row { flex-direction: column; }
  .form-row label { width: 100%; min-width: unset; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

/* ── Card als einklappbarer Block ────────────────────────────────────────── */
.card-details {
  padding: 0;
  overflow: hidden;
}
.card-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-3);
  transition: background .12s;
}
.card-summary::-webkit-details-marker { display: none; }
.card-summary:hover { background: #f8faf8; }
.card-details[open] .card-summary { border-bottom: 1px solid var(--border-lt); }

.card-summary span:first-child { flex: 1; }
.card-summary-meta {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  text-transform: none;
  letter-spacing: 0;
}
.card-details-body { padding: 16px 22px 18px; }

/* ── Chips ───────────────────────────────────────────────────────────────── */
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px 5px 12px;
  background: var(--green-lt);
  border: 1px solid #c3dfc9;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
}
.chip:hover { background: #d4ebd9; border-color: #a8cdb1; }
.chip-x {
  font-size: 15px;
  line-height: 1;
  color: var(--text-3);
  font-weight: 400;
}
.chip:hover .chip-x { color: #b91c1c; }

/* ── Akkordeon (Schüler-Einträge) ────────────────────────────────────────── */
.accordion { display: flex; flex-direction: column; gap: 6px; }

.accordion-item {
  border: 1px solid var(--border);
  border-radius: 5px;
  overflow: hidden;
  background: var(--surface);
}
.accordion-item[open] { border-color: #d4a09a; }

.accordion-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  background: var(--surface);
  transition: background .12s;
}
.accordion-summary::-webkit-details-marker { display: none; }
.accordion-summary:hover { background: #fdf7f7; }
.accordion-item[open] .accordion-summary { background: var(--primary-lt); }

.accordion-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  flex: 1;
}
.accordion-meta {
  font-size: 13px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.accordion-meta strong { color: var(--green); font-weight: 700; }
.sep { color: var(--border); }

.accordion-arrow {
  font-size: 18px;
  color: var(--text-3);
  transition: transform .2s;
  line-height: 1;
}
.accordion-item[open] .accordion-arrow { transform: rotate(90deg); }

.accordion-body {
  padding: 0 16px 14px;
  border-top: 1px solid var(--border-lt);
}
.accordion-body table { margin-top: 10px; }
.accordion-body th { background: #f8f9fb; }
.accordion-body td { font-size: 13.5px; }

/* ── Highlight-Animation nach Eintrag ────────────────────────────────────── */
@keyframes highlight-pulse {
  0%   { background: var(--surface); }
  25%  { background: #fde8e6; box-shadow: 0 0 0 2px var(--primary); }
  75%  { background: #fde8e6; box-shadow: 0 0 0 2px var(--primary); }
  100% { background: var(--surface); }
}
.accordion-highlight {
  animation: highlight-pulse 2.8s ease forwards;
}
.accordion-highlight .accordion-summary {
  background: #fde8e6 !important;
}
