:root {
  --ink: #20242e;
  --muted: #6f7481;
  --line: #e6e8ed;
  --paper: #ffffff;
  --surface: #f7f7fb;
  --violet: #a349a4;
  --blue: #3f48cc;
  --red: #ed1c24;
  --orange: #ff7f27;
  --yellow: #fff200;
  --green: #22b14c;
  --cyan: #00a2e8;
  --shadow: 0 18px 50px rgba(32, 36, 46, 0.10);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #ffffff 0, var(--surface) 320px, #ffffff 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(210px, 300px) 1fr auto;
  align-items: center;
  gap: 24px;
  min-height: 86px;
  padding: 14px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid rgba(230, 232, 237, 0.9);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  width: min(270px, 100%);
}

.brand img {
  display: block;
  width: 100%;
  max-height: 62px;
  object-fit: contain;
}

.main-nav {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.main-nav a,
.panel-action-label,
.secondary-action {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #3f3444;
  text-decoration: none;
}

.main-nav a {
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  white-space: nowrap;
}

.main-nav a:hover,
.secondary-action:hover {
  border-color: rgba(163, 73, 164, 0.22);
  background: rgba(163, 73, 164, 0.08);
}

.main-nav a.is-active {
  color: #fff;
  background: var(--violet);
  box-shadow: 0 10px 24px rgba(163, 73, 164, 0.18);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.sync-label {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--violet);
  font-size: 1.25rem;
}

.icon-button.is-loading {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 54px;
}

.page-header {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  align-items: stretch;
  gap: 22px;
  min-height: 210px;
  margin-bottom: 18px;
  padding: clamp(24px, 4vw, 42px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.page-header h1 {
  margin-bottom: 12px;
}

.page-header-mark {
  min-height: 140px;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--red) 0 14%, var(--orange) 14% 28%, var(--yellow) 28% 42%, var(--green) 42% 56%, var(--cyan) 56% 70%, var(--blue) 70% 84%, var(--violet) 84% 100%);
  clip-path: polygon(24% 0, 100% 0, 76% 100%, 0 100%);
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(340px, 1.05fr);
  gap: 24px;
  align-items: stretch;
}

.hero-copy,
.hero-visual,
.panel,
.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 330px;
  padding: clamp(24px, 4vw, 44px);
  overflow: hidden;
  position: relative;
}

.hero-copy::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 8px;
  background: linear-gradient(180deg, var(--red), var(--orange), var(--yellow), var(--green), var(--cyan), var(--blue), var(--violet));
}

.eyebrow,
.panel-kicker {
  margin: 0 0 10px;
  color: var(--violet);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 16px;
  font-size: clamp(2.2rem, 5vw, 4.8rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.intro {
  max-width: 650px;
  color: var(--muted);
  font-size: 1.02rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.primary-action,
.secondary-action,
.ghost-button {
  padding: 0 16px;
}

.primary-action {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--violet);
  box-shadow: 0 10px 22px rgba(163, 73, 164, 0.22);
}

.secondary-action,
.ghost-button {
  border-color: var(--line);
  background: #fff;
}

.hero-visual {
  position: relative;
  min-height: 330px;
  overflow: hidden;
  background-position: center;
  background-size: cover;
}

.hero-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(32, 36, 46, 0.40), rgba(32, 36, 46, 0.02));
}

.rainbow-ribbon {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 1;
  width: min(300px, 48%);
  height: 108px;
  background: linear-gradient(180deg, var(--red) 0 14%, var(--orange) 14% 28%, var(--yellow) 28% 42%, var(--green) 42% 56%, var(--cyan) 56% 70%, var(--blue) 70% 84%, var(--violet) 84% 100%);
  clip-path: polygon(26% 0, 100% 0, 100% 100%, 0 100%);
  box-shadow: 0 12px 30px rgba(32, 36, 46, 0.18);
}

.route-card {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 2;
  display: grid;
  gap: 3px;
  width: min(260px, calc(100% - 36px));
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 8px;
  color: #fff;
  background: rgba(32, 36, 46, 0.56);
  backdrop-filter: blur(12px);
}

.route-card span,
.route-card small {
  color: rgba(255, 255, 255, 0.78);
}

.route-card strong {
  font-size: 1.35rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0 24px;
}

.summary-count-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.overview-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.quick-card {
  position: relative;
  display: grid;
  align-content: start;
  min-height: 210px;
  padding: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  box-shadow: var(--shadow);
  text-decoration: none;
}

.quick-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, var(--red), var(--orange), var(--yellow), var(--green), var(--cyan), var(--blue), var(--violet));
}

.quick-card h2 {
  margin: 0 0 10px;
  font-size: 1.55rem;
}

.quick-card p {
  margin-bottom: 20px;
  color: var(--muted);
}

.quick-card strong {
  align-self: end;
  color: var(--violet);
}

.quick-card:hover {
  border-color: rgba(163, 73, 164, 0.32);
  transform: translateY(-2px);
}

.metric {
  position: relative;
  min-height: 128px;
  padding: 16px;
  overflow: hidden;
}

.metric::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: var(--accent, var(--violet));
}

.metric-label,
.metric small {
  display: block;
  color: var(--muted);
}

.metric-label {
  font-size: 0.82rem;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin: 12px 0 2px;
  font-size: 2.25rem;
  line-height: 1;
}

.metric-violet,
.metric-purple {
  --accent: var(--violet);
}

.metric-green {
  --accent: var(--green);
}

.metric-blue {
  --accent: var(--blue);
}

.metric-red {
  --accent: var(--red);
}

.metric-yellow {
  --accent: #f4c400;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.22fr);
  grid-auto-flow: dense;
  gap: 18px;
}

.single-column {
  display: grid;
  gap: 18px;
}

.single-column .fleet-panel {
  grid-row: auto;
}

.disposition-grid {
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
  gap: 18px;
  align-items: start;
}

.map-panel {
  min-height: 620px;
}

.map-shell {
  position: relative;
  min-height: 520px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #edf1f4;
}

.route-map {
  width: 100%;
  min-height: 520px;
}

.route-map .leaflet-container,
.leaflet-container {
  font: inherit;
}

.leaflet-control-attribution {
  font-size: 0.68rem;
}

.map-unavailable {
  position: absolute;
  inset: 16px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(163, 73, 164, 0.35);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.86);
  text-align: center;
}

.mapped-route-panel {
  position: sticky;
  top: 110px;
}

.assistant-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(310px, 0.65fr);
  gap: 18px;
  align-items: start;
}

.assistant-panel {
  min-height: 620px;
}

.assistant-messages {
  display: grid;
  gap: 12px;
  max-height: 390px;
  min-height: 300px;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f8fb;
}

.assistant-message {
  width: min(76%, 620px);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.assistant-message span {
  display: block;
  margin-bottom: 6px;
  color: var(--violet);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.assistant-message p {
  margin: 0;
  color: var(--ink);
}

.message-user {
  justify-self: end;
  color: #fff;
  border-color: transparent;
  background: var(--violet);
}

.message-user span,
.message-user p {
  color: #fff;
}

.assistant-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.assistant-prompts button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(163, 73, 164, 0.22);
  border-radius: 999px;
  color: var(--violet);
  background: rgba(163, 73, 164, 0.08);
  font-weight: 800;
}

.assistant-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.assistant-input textarea {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
}

.assistant-context-list {
  display: grid;
  gap: 12px;
}

.assistant-context-list article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.assistant-context-list strong {
  display: block;
  margin-bottom: 6px;
}

.assistant-context-list p {
  margin: 0;
  color: var(--muted);
}

.assistant-side-action {
  width: 100%;
  margin-top: 16px;
}

.mapped-route-list {
  display: grid;
  gap: 12px;
}

.mapped-route-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.route-card-head {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
}

.route-color {
  width: 12px;
  height: 100%;
  min-height: 38px;
  border-radius: 999px;
}

.route-card-head strong,
.route-card-head small {
  display: block;
}

.route-card-head small {
  color: var(--muted);
}

.route-card-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.route-card-meta span {
  min-height: 34px;
  padding: 7px 8px;
  border-radius: 8px;
  color: var(--muted);
  background: #f6f7fa;
  font-size: 0.86rem;
  font-weight: 800;
  text-align: center;
}

.route-stops {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: stop;
}

.route-stops li {
  position: relative;
  min-height: 30px;
  padding-left: 34px;
  color: var(--muted);
}

.route-stops li::before {
  counter-increment: stop;
  content: counter(stop);
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  color: #fff;
  background: var(--violet);
  font-size: 0.75rem;
  font-weight: 900;
}

.panel {
  min-width: 0;
  padding: 20px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.2;
}

.panel-action-label {
  min-width: 96px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  color: var(--muted);
  background: #fff;
  white-space: nowrap;
}

.ghost-button {
  min-width: 96px;
  white-space: nowrap;
}

.fleet-panel {
  grid-row: span 2;
}

.deadline-list,
.fleet-list,
.route-list,
.activity-list {
  display: grid;
  gap: 10px;
}

.deadline,
.vehicle-row,
.route-item {
  display: grid;
  align-items: center;
  gap: 12px;
  min-height: 66px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.deadline {
  grid-template-columns: 12px minmax(110px, 1fr) auto auto auto;
  padding: 10px 12px;
}

.deadline strong,
.vehicle-main strong,
.route-item strong {
  display: block;
}

.deadline small,
.vehicle-main small,
.route-item small {
  color: var(--muted);
}

.state-dot,
.vehicle-signal {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  background: var(--green);
}

.deadline-überfällig .state-dot,
.signal-danger {
  background: var(--red);
}

.deadline-fällig .state-dot,
.signal-warning {
  background: #f4c400;
}

.deadline-type {
  font-weight: 800;
}

.deadline time {
  color: var(--muted);
  font-size: 0.92rem;
  white-space: nowrap;
}

.status-pill,
.vehicle-status,
.route-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill {
  color: #7d1b23;
  background: rgba(237, 28, 36, 0.12);
}

.fleet-toolbar {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto;
  gap: 12px;
  margin-bottom: 14px;
}

.search-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.search-field input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
}

.segment-control {
  display: grid;
  grid-template-columns: repeat(4, minmax(72px, 1fr));
  align-self: end;
  min-height: 42px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f5f8;
}

.segment-control button {
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.segment-control .is-active {
  color: #fff;
  background: var(--violet);
}

.vehicle-row {
  grid-template-columns: 12px minmax(190px, 1fr) minmax(110px, 0.4fr) minmax(96px, 0.55fr) auto;
  padding: 12px;
}

.vehicle-site {
  color: var(--muted);
  font-weight: 700;
}

.load-meter {
  height: 9px;
  overflow: hidden;
  border-radius: 99px;
  background: #eceef3;
}

.load-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--cyan), var(--blue));
}

.vehicle-status {
  color: #1b5f31;
  background: rgba(34, 177, 76, 0.13);
}

.status-werkstatt {
  color: #5a4210;
  background: rgba(244, 196, 0, 0.20);
}

.status-prüfen {
  color: #7d1b23;
  background: rgba(237, 28, 36, 0.12);
}

.route-item {
  grid-template-columns: minmax(180px, 1fr) auto auto;
  padding: 12px;
}

.passenger-count {
  color: var(--muted);
  font-weight: 800;
}

.route-pünktlich {
  color: #1b5f31;
  background: rgba(34, 177, 76, 0.13);
}

.route-beobachten {
  color: #5a4210;
  background: rgba(244, 196, 0, 0.20);
}

.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.activity-list li {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 12px;
  padding: 0 0 14px;
  border-bottom: 1px solid var(--line);
}

.activity-list li:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.activity-list time {
  color: var(--violet);
  font-weight: 900;
}

.activity-list p {
  margin: 4px 0 0;
  color: var(--muted);
}

@media (max-width: 1040px) {
  .topbar {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .main-nav {
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .topbar-actions {
    justify-content: space-between;
  }

  .hero-panel,
  .content-grid,
  .page-header,
  .overview-links,
  .map-layout,
  .assistant-layout {
    grid-template-columns: 1fr;
  }

  .mapped-route-panel {
    position: static;
  }

  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .page-header-mark {
    min-height: 68px;
  }
}

@media (max-width: 760px) {
  .page {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .main-nav {
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .main-nav a {
    flex: 1 1 calc(50% - 8px);
    justify-content: center;
  }

  .hero-copy,
  .hero-visual {
    min-height: 280px;
  }

  h1 {
    font-size: 2.35rem;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .fleet-toolbar,
  .assistant-form,
  .deadline,
  .vehicle-row,
  .route-item,
  .route-card-head,
  .route-card-meta {
    grid-template-columns: 1fr;
  }

  .map-panel,
  .map-shell,
  .route-map {
    min-height: 430px;
  }

  .state-dot,
  .vehicle-signal {
    display: none;
  }

  .segment-control {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .deadline time,
  .vehicle-site,
  .load-meter,
  .vehicle-status,
  .route-state {
    justify-self: start;
  }
}

@media (max-width: 480px) {
  .topbar {
    padding: 12px;
  }

  .brand {
    width: min(235px, 100%);
  }

  .main-nav a {
    padding: 0 10px;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .hero-actions {
    display: grid;
  }

  .primary-action,
  .secondary-action {
    width: 100%;
  }
}
