:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --ink: #1a2233;
  --muted: #5b6577;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --border: #e3e8f0;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.05);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

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

a { color: inherit; text-decoration: none; }

/* Header / Navigation */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.app-header__inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  font-size: 1.15rem;
}

.brand__logo { font-size: 1.4rem; }

.nav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.nav__link {
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.95rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav__link:hover { background: #eef2fb; color: var(--ink); }
.nav__link.is-active { background: var(--brand); color: #fff; }

/* Layout */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

/* Hero */
.hero {
  background: linear-gradient(135deg, #eef3ff 0%, #f7f9ff 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.25rem 1.75rem;
  box-shadow: var(--shadow);
}

.hero h1 {
  margin: 0 0 0.6rem;
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  line-height: 1.2;
}

.hero__lead {
  margin: 0 0 1.4rem;
  color: var(--muted);
  max-width: 55ch;
  font-size: 1.05rem;
}

.hero__actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.25rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.98rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.05s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-dark); }
.btn--ghost { background: #fff; border-color: var(--border); color: var(--ink); }
.btn--ghost:hover { border-color: var(--brand); color: var(--brand); }

/* Cards */
.cards {
  margin-top: 1.75rem;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.card__icon {
  font-size: 1.6rem;
  margin-bottom: 0.4rem;
}

.card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* Status */
.status {
  margin-top: 1.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.status h2 { margin: 0 0 0.4rem; font-size: 1.05rem; }
.status__line { margin: 0; color: var(--muted); font-size: 0.95rem; }

/* Footer */
.app-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 1.25rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Card-Link */
.card__link { color: var(--brand); font-weight: 600; font-size: 0.9rem; }
.card__link:hover { color: var(--brand-dark); }

/* -- Reps-Verwaltung ---------------------------------------------------- */
.page-head { margin-bottom: 1.25rem; }
.page-head h1 { margin: 0 0 0.4rem; font-size: clamp(1.4rem, 3.5vw, 2rem); }

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

.notice {
  border-radius: 10px;
  padding: 0.7rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  background: var(--surface);
}
.notice--success { border-color: #b7e4c7; background: #eafaf0; color: #14663a; }
.notice--error { border-color: #f4c4c4; background: #fdecec; color: #8a1c1c; }
.notice--info { border-color: var(--border); background: #eef2fb; color: var(--ink); }

.layout {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: minmax(280px, 360px) 1fr;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 0.9rem; font-size: 1.15rem; }
.panel__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; margin-bottom: 0.9rem; flex-wrap: wrap;
}
.panel__head h2 { margin: 0; }

/* Formular */
.form { display: flex; flex-direction: column; gap: 0.85rem; }
.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field__label { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.field-row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-end; }
.field--color { flex: 0 0 auto; }
.field--check { flex: 1 1 auto; }

.input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}
.input:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.input--color { padding: 0.2rem; height: 2.6rem; width: 3.5rem; cursor: pointer; }

.check { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.55rem 0; }
.check input { width: 1.05rem; height: 1.05rem; }

.form__actions { display: flex; gap: 0.6rem; }

.btn--sm { padding: 0.4rem 0.75rem; font-size: 0.85rem; border-radius: 8px; }
.btn--danger { background: #dc2626; color: #fff; }
.btn--danger:hover { background: #b91c1c; }

/* Rep-Liste */
.rep-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1rem; }

.rep-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  background: #fff;
}
.rep-card__head { display: flex; align-items: center; gap: 0.75rem; }
.rep-card__swatch {
  width: 1.35rem; height: 1.35rem; border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.08); flex: 0 0 auto;
}
.rep-card__title { display: flex; align-items: center; gap: 0.55rem; flex: 1 1 auto; min-width: 0; }
.rep-card__name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rep-card__actions { display: flex; gap: 0.4rem; flex: 0 0 auto; }

.badge {
  font-size: 0.75rem; font-weight: 700; padding: 0.15rem 0.55rem;
  border-radius: 999px; text-transform: uppercase; letter-spacing: 0.02em;
}
.badge--ok { background: #eafaf0; color: #14663a; }
.badge--off { background: #f1f3f7; color: var(--muted); }

.rep-card__body { margin-top: 0.85rem; display: flex; flex-direction: column; gap: 0.9rem; }

.feed {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  background: #f7f9ff; border: 1px dashed var(--border);
  border-radius: 10px; padding: 0.6rem 0.75rem;
}
.feed__label { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.feed__url { font-size: 0.82rem; word-break: break-all; color: var(--ink); }

.sources__title { margin: 0 0 0.5rem; font-size: 0.95rem; }
.source-list { list-style: none; margin: 0 0 0.6rem; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.source-item {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.5rem 0.65rem; border: 1px solid var(--border);
  border-radius: 9px; background: #fafbfe;
}
.source-item__info { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.source-item__label { font-weight: 600; font-size: 0.9rem; }
.source-item__url { font-size: 0.8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-item__url:hover { color: var(--brand); }
.source-item__status { font-size: 0.78rem; margin-top: 0.15rem; line-height: 1.35; }
.source-item__status--ok { color: #14663a; }
.source-item__status--pending { color: var(--muted); }
.source-item__status--error {
  color: #b91c1c; font-weight: 600;
  overflow-wrap: anywhere;
}

.source-form { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.source-form .input { flex: 1 1 180px; }

/* -- Buchung / Verfügbarkeit / Termine ---------------------------------- */
.booking { margin-top: 1.75rem; display: flex; flex-direction: column; gap: 1.25rem; }
.booking__grid {
  display: grid; gap: 1.25rem;
  grid-template-columns: minmax(320px, 1.1fr) minmax(280px, 0.9fr);
  align-items: start;
}

textarea.input { resize: vertical; font: inherit; }
select.input { appearance: auto; background: #fff; }

/* Verfügbarkeits-Panel */
.avail-summary {
  margin: 0 0 0.75rem; font-size: 0.95rem; font-weight: 600;
  padding: 0.6rem 0.75rem; border-radius: 10px;
  background: #eef2fb; border: 1px solid var(--border); color: var(--ink);
}
.avail-summary--ok { background: #eafaf0; border-color: #b7e4c7; color: #14663a; }
.avail-summary--warn { background: #fff6e6; border-color: #f3d9a3; color: #8a5a00; }

.avail-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.avail-item {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.5rem 0.65rem; border: 1px solid var(--border);
  border-radius: 9px; background: #fafbfe;
}
.avail-item--free { background: #f2fbf5; border-color: #cdeed7; }
.avail-item--busy { opacity: 0.75; }
.avail-item__swatch {
  width: 1rem; height: 1rem; border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.08); flex: 0 0 auto;
}
.avail-item__name { font-weight: 600; font-size: 0.92rem; flex: 1 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avail-item__tag { font-size: 0.8rem; color: var(--muted); flex: 0 0 auto; }
.avail-item--free .avail-item__tag { color: #14663a; font-weight: 600; }

/* Terminliste */
.appt-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.appt-card {
  display: flex; align-items: flex-start; gap: 0.75rem;
  border: 1px solid var(--border); border-radius: 12px;
  padding: 0.85rem 1rem; background: #fff;
}
.appt-card__swatch {
  width: 0.9rem; height: 0.9rem; border-radius: 50%; margin-top: 0.3rem;
  border: 1px solid rgba(0,0,0,0.08); flex: 0 0 auto;
}
.appt-card__main { flex: 1 1 auto; min-width: 0; }
.appt-card__title { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; }
.appt-card__meta { font-size: 0.85rem; color: var(--muted); margin-top: 0.15rem; }
.appt-card__customer { font-size: 0.85rem; color: var(--ink); margin-top: 0.15rem; }
.appt-card__side { display: flex; flex-direction: column; gap: 0.4rem; flex: 0 0 auto; align-items: stretch; }
.field--reassign { gap: 0.2rem; }
.input--sm { padding: 0.35rem 0.5rem; font-size: 0.85rem; border-radius: 8px; min-width: 9rem; }

/* -- Zentraler Team-Kalender -------------------------------------------- */
.cal { display: flex; flex-direction: column; gap: 1rem; }

.cal-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem 1rem; flex-wrap: wrap;
}
.cal-toolbar__nav { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.cal-toolbar__controls { display: flex; align-items: flex-end; gap: 0.75rem; flex-wrap: wrap; }
.cal-range { font-weight: 700; font-size: 1rem; margin-left: 0.4rem; }

.cal-views { display: inline-flex; gap: 0.25rem; background: #eef2fb; padding: 0.2rem; border-radius: 999px; }
.cal-view { background: transparent; border: none; color: var(--muted); border-radius: 999px; }
.cal-view:hover { color: var(--ink); }
.cal-view.is-active { background: var(--brand); color: #fff; }

.cal-filter { flex: 0 0 auto; min-width: 12rem; }

.cal-legend { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.cal-chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.3rem 0.65rem; border: 1px solid var(--border);
  border-radius: 999px; background: #fff; cursor: pointer;
  font-size: 0.85rem; font-weight: 600; color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.cal-chip:hover { border-color: var(--brand); }
.cal-chip.is-active { border-color: var(--brand); background: #eef2fb; }
.cal-chip__dot { width: 0.8rem; height: 0.8rem; border-radius: 50%; border: 1px solid rgba(0,0,0,0.08); flex: 0 0 auto; }

.cal-empty { margin: 0.5rem 0; }

/* Zeitraster (Woche/Tag) */
.cal-viewport--grid { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cal-timegrid { min-width: 640px; }
.cal-viewport--grid .cal-timegrid { min-width: 0; }

.cal-timegrid__head { display: flex; position: sticky; top: 0; z-index: 3; background: var(--surface); }
.cal-timegrid__corner { flex: 0 0 3.4rem; }
.cal-colhead {
  flex: 1 1 0; min-width: 0; text-align: center; padding: 0.4rem 0.25rem;
  border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 0.1rem;
}
.cal-colhead__dow { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.cal-colhead__date { font-weight: 700; font-size: 0.9rem; }
.cal-colhead.is-today { background: #eef2fb; }
.cal-colhead.is-today .cal-colhead__date { color: var(--brand); }

.cal-timegrid__body { display: flex; }
.cal-axis { flex: 0 0 3.4rem; position: relative; }
.cal-axis__hour {
  font-size: 0.72rem; color: var(--muted); text-align: right;
  padding-right: 0.4rem; box-sizing: border-box; transform: translateY(-0.55em);
}

.cal-days { flex: 1 1 auto; display: grid; }
.cal-daycol { position: relative; border-left: 1px solid var(--border); }
.cal-daycol.is-today { background: rgba(37, 99, 235, 0.03); }
.cal-hourline { position: absolute; left: 0; right: 0; border-top: 1px solid var(--border); }

.cal-event {
  position: absolute; overflow: hidden; text-align: left;
  border: 1px solid rgba(0,0,0,0.06); border-radius: 7px;
  padding: 0.15rem 0.4rem; cursor: pointer; color: var(--ink);
  display: flex; flex-direction: column; gap: 0.05rem; line-height: 1.2;
  box-shadow: 0 1px 2px rgba(16,24,40,0.06);
}
.cal-event:hover { filter: brightness(0.97); box-shadow: 0 2px 6px rgba(16,24,40,0.12); }
.cal-event.is-cancelled { opacity: 0.55; }
.cal-event.is-cancelled .cal-event__title { text-decoration: line-through; }
.cal-event__time { font-size: 0.7rem; font-weight: 700; color: var(--muted); }
.cal-event__title { font-size: 0.8rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event__rep { font-size: 0.72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Listenansicht */
.cal-list { display: flex; flex-direction: column; gap: 1.25rem; }
.cal-list__group { display: flex; flex-direction: column; gap: 0.5rem; }
.cal-list__day {
  margin: 0; font-size: 0.95rem; color: var(--ink);
  padding-bottom: 0.3rem; border-bottom: 1px solid var(--border);
}
.cal-list__day.is-today { color: var(--brand); }
.cal-listitem {
  display: flex; align-items: center; gap: 0.75rem; width: 100%; text-align: left;
  padding: 0.6rem 0.85rem; border: 1px solid var(--border); border-radius: 10px;
  background: #fff; cursor: pointer;
}
.cal-listitem:hover { border-color: var(--brand); }
.cal-listitem.is-cancelled { opacity: 0.6; }
.cal-listitem.is-cancelled .cal-listitem__title { text-decoration: line-through; }
.cal-listitem__time { flex: 0 0 5.5rem; font-weight: 700; font-size: 0.9rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.cal-listitem__main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.cal-listitem__title { font-weight: 700; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-listitem__meta { font-size: 0.82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Detail-Dialog */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(16, 24, 40, 0.45); }
.modal__dialog {
  position: relative; z-index: 1; background: var(--surface);
  border-radius: var(--radius); box-shadow: var(--shadow);
  width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; padding: 1.25rem;
}
.modal__head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.9rem; }
.modal__swatch { width: 1.1rem; height: 1.1rem; border-radius: 50%; border: 1px solid rgba(0,0,0,0.08); flex: 0 0 auto; }
.modal__title { margin: 0; font-size: 1.15rem; flex: 1 1 auto; min-width: 0; }
.modal__close {
  flex: 0 0 auto; border: none; background: transparent; font-size: 1.5rem;
  line-height: 1; color: var(--muted); cursor: pointer; padding: 0 0.25rem;
}
.modal__close:hover { color: var(--ink); }
.modal__body { display: grid; grid-template-columns: 7rem 1fr; gap: 0.4rem 0.75rem; margin: 0; }
.modal__body dt { font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.modal__body dd { margin: 0; font-size: 0.92rem; overflow-wrap: anywhere; }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .booking__grid { grid-template-columns: 1fr; }
  .cal-timegrid { min-width: 720px; }
}

@media (max-width: 560px) {
  .nav { width: 100%; justify-content: flex-start; }
  .hero { padding: 1.75rem 1.25rem; }
  .rep-card__actions { flex-wrap: wrap; }
  .appt-card { flex-wrap: wrap; }
  .appt-card__side { flex-direction: row; width: 100%; }
  .cal-toolbar { flex-direction: column; align-items: stretch; }
  .cal-toolbar__controls { justify-content: space-between; }
  .cal-filter { flex: 1 1 auto; min-width: 0; }
  .cal-listitem__time { flex-basis: 4.5rem; font-size: 0.85rem; }
  .modal__body { grid-template-columns: 6rem 1fr; }
}
