:root {
  --asb-red: #e2001a;
  --asb-red-dark: #b50015;
  --ink: #1f2328;
  --muted: #5d6670;
  --line: #d9dde2;
  --bg: #f3f4f6;
  --white: #fff;
  --green: #17693a;
  --green-bg: #e4f3ea;
  --blue: #1b5a96;
  --blue-bg: #e3eef8;
  --amber: #8a5a00;
  --amber-bg: #fbf0d9;
  --grey-bg: #e8eaed;
  --red-bg: #fde8ea;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 "Helvetica Neue", Helvetica, Arial, "Segoe UI", sans-serif;
}
h1, h2 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.1rem; }
a { color: var(--asb-red-dark); }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.main { flex: 1; padding-top: 24px; padding-bottom: 40px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.break { overflow-wrap: anywhere; }
.text-error { color: var(--asb-red-dark); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Kopf */
.site-header { background: var(--white); }
.header-inner { display: flex; align-items: center; gap: 20px; padding-top: 12px; padding-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand-mark { color: var(--asb-red); font-size: 2rem; font-weight: 800; letter-spacing: .02em; line-height: 1; }
.brand-org { font-size: .78rem; line-height: 1.2; color: var(--ink); border-left: 2px solid var(--asb-red); padding-left: 10px; }
.brand-logo { height: 44px; width: auto; display: block; }
.app-title { font-weight: 600; color: var(--muted); }
.user-box { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: .9rem; }
.user-box a { color: var(--ink); }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--asb-red-dark); text-decoration: underline; cursor: pointer; }

.site-nav { background: var(--asb-red); }
.nav-inner { display: flex; gap: 2px; overflow-x: auto; }
.site-nav a { color: var(--white); text-decoration: none; padding: 11px 14px; font-weight: 600; font-size: .95rem; white-space: nowrap; }
.site-nav a:hover { background: var(--asb-red-dark); }
.site-nav a.active { background: var(--white); color: var(--asb-red-dark); }
.count { display: inline-block; min-width: 1.5em; padding: 0 .4em; border-radius: 1em; text-align: center; font-size: .78rem; background: var(--white); color: var(--asb-red-dark); }
.site-nav a.active .count { background: var(--asb-red); color: var(--white); }

.site-footer { background: var(--white); border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; padding: 12px 0; }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* Seitenkopf, Suche, Reiter */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.search { display: flex; gap: 6px; flex: 0 1 380px; }
.search input { flex: 1; min-width: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 8px 14px; color: var(--muted); text-decoration: none; font-weight: 600; margin-bottom: -2px; border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--asb-red-dark); border-bottom-color: var(--asb-red); }

/* Formulare */
input[type=text], input[type=email], input[type=password], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; font: inherit; color: inherit; background: var(--white);
  border: 1px solid #aab1b9; border-radius: 3px;
}
:focus-visible { outline: 3px solid #1b5a96; outline-offset: 1px; }
.form { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.form label { display: block; width: 100%; font-weight: 600; font-size: .9rem; }
.form label input, .form label select { margin-top: 4px; font-weight: 400; }
.form label.check { display: flex; align-items: center; gap: 8px; }
.form label.check input { margin: 0; }
.form textarea { resize: vertical; }
.hint { display: block; font-weight: 400; font-size: .82rem; color: var(--muted); margin-top: 3px; }

/* Schaltflächen */
.btn {
  display: inline-block; padding: 8px 13px; font: inherit; font-size: .92rem; font-weight: 600; line-height: 1.3;
  color: var(--ink); background: var(--white); border: 1px solid #aab1b9; border-radius: 3px;
  text-decoration: none; cursor: pointer; text-align: center;
}
.btn:hover { background: var(--grey-bg); }
.btn-primary { background: var(--asb-red); border-color: var(--asb-red); color: var(--white); }
.btn-primary:hover { background: var(--asb-red-dark); border-color: var(--asb-red-dark); }
.btn-success { background: var(--green); border-color: var(--green); color: var(--white); }
.btn-success:hover { background: #115029; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--asb-red-dark); }
.btn-block { width: 100%; }
.btn-call { font-size: 1.05rem; white-space: nowrap; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* Rückruf-Karten */
.call-card {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: start;
  background: var(--white); border: 1px solid var(--line); border-left: 5px solid var(--grey-bg);
  border-radius: 3px; padding: 14px 16px; margin-bottom: 10px;
}
.call-card.status-neu { border-left-color: var(--asb-red); }
.call-card.status-in_bearbeitung { border-left-color: var(--blue); }
.call-card.status-nicht_erreicht { border-left-color: #d29a1f; }
.call-card.status-erreicht { border-left-color: var(--green); }
.call-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.call-head h2 { font-size: 1.1rem; }
.call-head h2 a { color: var(--ink); text-decoration: none; }
.call-head h2 a:hover { text-decoration: underline; }
.call-meta { margin: 3px 0 6px; color: var(--muted); font-size: .875rem; }
.call-concern { margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.call-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.call-actions .btn-row { justify-content: flex-end; }
.call-actions form { margin: 0; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 2px; font-size: .76rem; font-weight: 700; white-space: nowrap; }
.badge-neu { background: var(--red-bg); color: var(--asb-red-dark); }
.badge-in_bearbeitung { background: var(--blue-bg); color: var(--blue); }
.badge-nicht_erreicht { background: var(--amber-bg); color: var(--amber); }
.badge-erreicht { background: var(--green-bg); color: var(--green); }
.badge-erledigt { background: var(--grey-bg); color: var(--muted); }
.badge-overdue { background: var(--asb-red-dark); color: var(--white); }

.empty { background: var(--white); border: 1px dashed #b7bdc4; border-radius: 3px; padding: 32px 16px; text-align: center; color: var(--muted); }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 16px; }

/* Panels */
.panel { background: var(--white); border: 1px solid var(--line); border-radius: 3px; padding: 18px; margin-bottom: 14px; }
.panel h2 { margin-bottom: 10px; }
.panel.narrow { max-width: 480px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.main > h1 { margin-bottom: 14px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: start; }
.facts { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 4px 12px; margin: 14px 0 18px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.concern-full { margin: 0 0 18px; overflow-wrap: anywhere; }
.panel .call-actions { align-items: flex-start; }
.panel .call-actions .btn-row { justify-content: flex-start; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: .9rem; }
.timeline li { padding: 8px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.timeline li:first-child { border-top: 0; padding-top: 0; }
.timeline-meta { color: var(--muted); font-size: .78rem; }

/* Tabellen */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; color: var(--muted); font-size: .8rem; border-bottom: 2px solid var(--line); padding: 6px 8px; }
.table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.table tr.inactive td { color: var(--muted); }

/* Meldungen */
.alert { padding: 10px 14px; border-radius: 3px; margin-bottom: 14px; border-left: 4px solid; overflow-wrap: anywhere; }
.alert-success { background: var(--green-bg); border-color: var(--green); }
.alert-error { background: var(--red-bg); border-color: var(--asb-red); }
.alert-info { background: var(--blue-bg); border-color: var(--blue); }
.toast { position: fixed; right: 16px; bottom: 16px; z-index: 10; background: var(--ink); color: var(--white); padding: 12px 18px; border-radius: 3px; font-weight: 600; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.toast[hidden] { display: none; }

/* Anmeldung */
.login-page { align-items: center; justify-content: center; background: var(--asb-red); padding: 16px; }
.login-box { width: 100%; max-width: 400px; background: var(--white); border-radius: 3px; padding: 28px; }
.login-brand { margin-bottom: 18px; }
.login-box h1 { font-size: 1.3rem; margin-bottom: 16px; }
.login-box .small { margin: 16px 0 0; }

@media (max-width: 860px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .call-card { grid-template-columns: minmax(0, 1fr); }
  .call-actions, .call-actions .btn-row { align-items: stretch; justify-content: flex-start; }
  .btn-call { display: block; }
  .call-actions .btn-row form { flex: 1 1 auto; }
  .call-actions .btn-row .btn { width: 100%; }
  .app-title { display: none; }
  .search { flex-basis: 100%; }
}

@media (max-width: 640px) {
  .brand-org { white-space: nowrap; }
  .user-box a { display: none; }
  .table thead { display: none; }
  .table tr { display: block; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .table td { display: block; border: 0; padding: 2px 0; }
  .table td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .8rem; }
}
