:root {
  --brand: #d32f2f;
  --brand-dark: #a82222;
  --brand-soft: #fdeaea;
  --ink: #14161a;
  --ink-2: #2a2e35;
  --muted: #6b7280;
  --line: #e6e8ec;
  --bg: #f4f5f7;
  --card: #ffffff;
  --ok: #1f8a4c;
  --ok-soft: #e7f6ec;
  --warn: #b26a00;
  --warn-soft: #fff4e0;
  --info: #1d4ed8;
  --info-soft: #e8eefc;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.45;
}

a {
  color: var(--brand);
}
h1,
h2,
h3,
h4 {
  margin: 0 0 6px;
  line-height: 1.2;
}
h1 {
  font-size: 24px;
}
h2 {
  font-size: 18px;
}
h3 {
  font-size: 15px;
}
p {
  margin: 0 0 10px;
}
small {
  font-size: 12px;
}

.boot {
  display: grid;
  place-items: center;
  height: 100vh;
  color: var(--muted);
}

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

.auth-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}
.auth-brand {
  background: linear-gradient(150deg, #1b1e24 0%, #2c1517 55%, #6d1a1a 100%);
  color: #fff;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-brand::after {
  content: "";
  position: absolute;
  right: -120px;
  bottom: -120px;
  width: 380px;
  height: 380px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(211, 47, 47, 0.55), transparent 70%);
}
.auth-brand .logo {
  font-size: 15px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #ffb3b3;
  font-weight: 700;
}
.auth-brand h1 {
  font-size: 40px;
  max-width: 460px;
  margin: 18px 0 12px;
}
.auth-brand p {
  color: #d9dbe0;
  max-width: 420px;
}
.auth-points {
  list-style: none;
  padding: 0;
  margin: 22px 0 0;
  display: grid;
  gap: 10px;
}
.auth-points li {
  display: flex;
  gap: 10px;
  align-items: center;
  color: #eceef2;
  font-size: 14px;
}
.auth-points li::before {
  content: "✓";
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  font-size: 12px;
}
.auth-side {
  display: grid;
  place-items: center;
  padding: 32px;
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 430px;
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px;
}
.tabs {
  display: flex;
  gap: 4px;
  background: #f0f1f4;
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 20px;
}
.tabs button {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 9px 8px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.tabs button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ------------------------------------------------------------ Shell ---- */

.shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--ink);
  color: #cfd3da;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 10px;
}
.sidebar .brand .mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--brand);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  font-size: 18px;
}
.sidebar .brand strong {
  color: #fff;
  font-size: 14px;
  display: block;
  line-height: 1.2;
}
.sidebar .brand span {
  font-size: 11px;
  color: #8b919b;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.nav-group {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #6f7681;
  padding: 14px 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  color: #cfd3da;
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.nav-item.active {
  background: var(--brand);
  color: #fff;
  font-weight: 600;
}
.nav-item .ico {
  width: 18px;
  text-align: center;
  opacity: 0.95;
}
.nav-item .pill {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 99px;
  padding: 1px 7px;
  font-size: 11px;
}
.sidebar .who {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 12px;
  font-size: 12px;
  color: #8b919b;
}
.sidebar .who strong {
  color: #fff;
  display: block;
  font-size: 13px;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--ink);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar button {
  background: rgba(255, 255, 255, 0.1);
  border: 0;
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
}
.content {
  padding: 26px 30px 60px;
  max-width: 1280px;
  width: 100%;
}
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-head p {
  color: var(--muted);
  margin: 2px 0 0;
  font-size: 13.5px;
}
.head-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ------------------------------------------------------------ Cards ---- */

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.card.tight {
  padding: 14px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.card-head h2,
.card-head h3 {
  margin: 0;
}
.grid {
  display: grid;
  gap: 16px;
}
.grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.grid.auto {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.split {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px;
  align-items: start;
}

.stat {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.stat .label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.stat .value {
  font-size: 26px;
  font-weight: 700;
  margin-top: 6px;
  letter-spacing: -0.02em;
}
.stat .sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.stat.accent {
  background: linear-gradient(140deg, #1b1e24, #4a1a1c);
  color: #fff;
}
.stat.accent .label,
.stat.accent .sub {
  color: #c9ccd3;
}

/* ------------------------------------------------------------ Tables --- */

.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--line);
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: #fff;
}
table.data th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 10px 12px;
  background: #fafbfc;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td {
  padding: 11px 12px;
  border-bottom: 1px solid #f1f2f5;
  vertical-align: middle;
}
table.data tr:last-child td {
  border-bottom: 0;
}
table.data tbody tr:hover {
  background: #fafbfc;
}
td.num,
th.num {
  text-align: right;
  white-space: nowrap;
}
.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* ------------------------------------------------------------- Bits ---- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  background: var(--brand);
  color: #fff;
  white-space: nowrap;
}
.btn:hover {
  background: var(--brand-dark);
}
.btn.ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}
.btn.ghost:hover {
  background: #f7f8fa;
}
.btn.subtle {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  padding: 6px 8px;
  font-weight: 500;
}
.btn.subtle:hover {
  color: var(--ink);
  background: #f2f3f6;
}
.btn.danger {
  background: #fff;
  border-color: #f0c9c9;
  color: #b3261e;
}
.btn.sm {
  padding: 6px 10px;
  font-size: 13px;
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 99px;
  padding: 3px 9px;
  font-size: 11.5px;
  font-weight: 600;
  background: #eef0f4;
  color: var(--ink-2);
  white-space: nowrap;
}
.badge.ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.badge.warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.badge.bad {
  background: var(--brand-soft);
  color: var(--brand-dark);
}
.badge.info {
  background: var(--info-soft);
  color: var(--info);
}

.field {
  margin-bottom: 12px;
}
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 5px;
}
.field .hint {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 4px;
}
input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(211, 47, 47, 0.25);
  border-color: var(--brand);
}
textarea {
  min-height: 84px;
  resize: vertical;
}
.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.row > * {
  flex: 1;
  min-width: 150px;
}

.progress {
  height: 8px;
  background: #eceef2;
  border-radius: 99px;
  overflow: hidden;
}
.progress > i {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: 99px;
}
.progress.ok > i {
  background: var(--ok);
}
.metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  padding: 7px 0;
  border-bottom: 1px dashed #eef0f4;
}
.metric:last-child {
  border-bottom: 0;
}
.metric span:last-child {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.checklist {
  display: grid;
  gap: 8px;
}
.check-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 9px 10px;
  border-radius: 10px;
  background: #fafbfc;
  border: 1px solid #f0f2f5;
}
.check-item .dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  background: #e7e9ee;
  color: #6b7280;
  flex: 0 0 20px;
  margin-top: 1px;
}
.check-item.ok .dot {
  background: var(--ok-soft);
  color: var(--ok);
}
.check-item.warn .dot {
  background: var(--warn-soft);
  color: var(--warn);
}
.check-item strong {
  font-size: 13.5px;
  display: block;
}
.check-item small {
  color: var(--muted);
}
.check-body {
  flex: 1;
  min-width: 0;
}
.check-item .btn.sm {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* ------------------------------------------- Ausbildungsdiagrammkarte ---- */

.back-link {
  font-size: 13px;
  text-decoration: none;
  color: var(--muted);
}
.card-status {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}
.card-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}
.card-sections {
  display: grid;
  gap: 16px;
}
.card-count {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}
.card-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 8px;
}
.card-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 7px 9px;
  border-radius: 10px;
  background: #fafbfc;
  border: 1px solid #f0f2f5;
}
.card-item.on {
  background: var(--ok-soft);
  border-color: #cfe8d7;
}
.card-item label {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  cursor: pointer;
}
.card-item input[type="checkbox"] {
  width: auto;
  flex: 0 0 auto;
  margin-top: 2px;
  accent-color: var(--brand);
}
.card-item .card-note {
  flex: 0 0 84px;
  font-size: 12px;
  padding: 4px 6px;
}
@media (max-width: 640px) {
  .card-items {
    grid-template-columns: 1fr;
  }
  .card-item .card-note {
    flex: 0 0 70px;
  }
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 26px 12px;
  font-size: 13.5px;
}

/* ------------------------------------------------------------- Chat ---- */

.chat {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 0;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-height: 62vh;
}
.chat-list {
  border-right: 1px solid var(--line);
  overflow-y: auto;
  max-height: 70vh;
}
.chat-item {
  padding: 12px 14px;
  border-bottom: 1px solid #f2f3f6;
  cursor: pointer;
}
.chat-item:hover {
  background: #fafbfc;
}
.chat-item.active {
  background: var(--brand-soft);
  border-left: 3px solid var(--brand);
}
.chat-item strong {
  font-size: 13.5px;
  display: block;
}
.chat-item small {
  color: var(--muted);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-pane {
  display: flex;
  flex-direction: column;
  min-height: 62vh;
}
.chat-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.chat-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  max-height: 58vh;
  background: #fbfbfc;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bubble {
  max-width: 72%;
  padding: 9px 13px;
  border-radius: 13px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble.mine {
  align-self: flex-end;
  background: var(--brand);
  color: #fff;
  border-color: transparent;
}
.bubble .meta {
  display: block;
  font-size: 10.5px;
  opacity: 0.7;
  margin-bottom: 3px;
}
.chat-input {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: #fff;
}

/* ------------------------------------------------------------ Modal ---- */

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(16, 18, 22, 0.55);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 60;
}
.modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}
.modal.wide {
  max-width: 780px;
}
.modal header {
  padding: 18px 20px 10px;
  border-bottom: 1px solid var(--line);
}
.modal .body {
  padding: 18px 20px;
}
.modal footer {
  padding: 12px 20px 18px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  z-index: 90;
  max-width: 90vw;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}
.toast.err {
  background: #9b1c1c;
}

/* ---------------------------------------------------------- Responsive -- */

@media (max-width: 980px) {
  .auth-wrap {
    grid-template-columns: 1fr;
  }
  .auth-brand {
    padding: 28px;
  }
  .auth-brand h1 {
    font-size: 28px;
  }
  .split,
  .grid.cols-2,
  .grid.cols-3,
  .grid.cols-4 {
    grid-template-columns: 1fr;
  }
  .chat {
    grid-template-columns: 1fr;
  }
  .chat-list {
    max-height: 34vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 262px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.4);
  }
  .topbar {
    display: flex;
  }
  .content {
    padding: 16px 14px 80px;
  }
  h1 {
    font-size: 20px;
  }
  .stat .value {
    font-size: 22px;
  }
}


/* Wochenkalender */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.cal-day { background: #fafafa; border: 1px solid #eee; border-radius: 8px; padding: 8px; min-height: 130px; }
.cal-head { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: #666; margin-bottom: 6px; }
.cal-block { background: #fff; border: 1px solid #eee; border-left: 3px solid #c0392b; border-radius: 6px; padding: 6px 8px; font-size: 12px; margin-bottom: 6px; }
.cal-block small { display: block; color: #666; }
.cal-block.off { border-left-color: #bbb; opacity: .6; }
/* Automatik-Termine heben sich im Kalender ab. */
.cal-block.automatik { border-left-color: #2f6fbf; background: #f2f6fd; }
/* Abgesagt/Ausfall: Fahrzeug und Zeit sind wieder frei – nicht mehr hervorheben. */
.cal-block.off.automatik { border-left-color: #bbb; background: #fff; }
.cal-empty { font-size: 12px; color: #bbb; }
@media (max-width: 900px) { .cal { grid-template-columns: 1fr; } .cal-day { min-height: auto; } }

/* ------------------------------------------------------- Tagesnachweis ---- */

.nachweis-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.nachweis-head > div > strong {
  display: block;
  font-size: 15px;
}
.nachweis-head > div > span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.nachweis-head .hint {
  max-width: 330px;
  font-size: 11.5px;
  color: var(--muted);
}
.nachweis-sigs {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}
@media (min-width: 680px) {
  .nachweis-sigs {
    grid-template-columns: 1fr 1fr;
  }
  .nachweis-sigs .sig-block:first-child {
    grid-column: 1 / -1;
  }
}
.sig-block {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #fff;
}
.sig-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 12.5px;
  margin-bottom: 6px;
}
.sig-head span {
  font-size: 11.5px;
  color: var(--muted);
  text-align: right;
}
.sig-pad {
  display: block;
  width: 100%;
  height: 120px;
  border: 1px dashed var(--line);
  border-radius: 9px;
  background: #fcfcfd;
  touch-action: none;
  cursor: crosshair;
}
.sig-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}
.sig-view {
  height: 84px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  border-bottom: 1px solid var(--line);
  background: #fcfcfd;
  border-radius: 9px 9px 0 0;
}
.sig-view img {
  max-width: 100%;
  max-height: 78px;
  object-fit: contain;
}

/* ------------------------------------------------------ Fahrschüler-Ampel -- */
.traffic {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.traffic.rot {
  background: #d32f2f;
}
.traffic.gelb {
  background: #f0a500;
}
.traffic.blau {
  background: #2f6fbf;
}
.traffic.gruen {
  background: #2e9e5b;
}
