:root {
  color-scheme: light;
  --ink: #172331;
  --muted: #6c7b8a;
  --line: #d8e2ea;
  --white: #ffffff;
  --blue-950: #102c4a;
  --blue-900: #153c63;
  --blue-800: #1d527f;
  --blue-700: #246a9f;
  --blue-100: #e8f1f8;
  --blue-gray: #eef4f8;
  --blue-gray-strong: #dbe7ef;
  --red: #d83b35;
  --red-dark: #b92c28;
  --green: #2f9f68;
  --shadow: 0 16px 38px rgba(16, 44, 74, 0.18);
  --soft-shadow: 0 8px 24px rgba(16, 44, 74, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 255, 255, 0.18), transparent 28%),
    linear-gradient(180deg, var(--blue-800) 0%, var(--blue-900) 46%, var(--blue-950) 100%);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.auth-screen {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 18px;
}

.auth-card {
  background: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin: 0 auto;
  max-width: 440px;
  padding: 22px;
  width: 100%;
}

.eyebrow,
.label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 5px;
  text-transform: uppercase;
}

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

h1 {
  font-size: 2.2rem;
  line-height: 1;
  margin-bottom: 10px;
}

.brand-logo {
  display: block;
  height: auto;
  max-width: 100%;
}

.brand-logo-large {
  margin: 0 0 14px;
  width: min(330px, 100%);
}

.brand-logo-small {
  width: 150px;
}

.auth-copy {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.42;
  margin-bottom: 18px;
}

.form-stack {
  display: grid;
  gap: 14px;
}

.auth-actions {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}

label,
legend {
  color: var(--ink);
  font-weight: 800;
}

input,
select,
textarea {
  background: #f8fbfd;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: block;
  margin-top: 7px;
  min-height: 48px;
  outline: none;
  padding: 11px 12px;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue-700);
  box-shadow: 0 0 0 3px rgba(36, 106, 159, 0.16);
}

textarea {
  min-height: 82px;
  resize: vertical;
}

.role-choice {
  border: 0;
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
}

.role-choice legend {
  margin-bottom: 10px;
}

.role-choice label {
  align-items: flex-start;
  background: var(--blue-gray);
  border: 1px solid var(--blue-gray-strong);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  min-height: 64px;
  padding: 13px;
}

.role-choice label:has(input:checked) {
  background: #fff5f4;
  border-color: rgba(216, 59, 53, 0.42);
  box-shadow: inset 4px 0 0 var(--red);
}

.role-choice input {
  accent-color: var(--red);
  margin: 3px 0 0;
  min-height: 20px;
  width: 20px;
}

.option-text {
  display: grid;
  gap: 3px;
}

.option-text strong {
  line-height: 1.2;
}

.option-text small {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.35;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: 24px;
}

.topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 6px 18px rgba(16, 44, 74, 0.16);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  padding: 12px 14px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.user-chip {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  min-width: 0;
}

.user-chip span,
.status {
  background: var(--blue-gray);
  border-radius: 999px;
  color: var(--blue-900);
  display: inline-block;
  font-size: 0.84rem;
  font-weight: 800;
  max-width: 155px;
  overflow: hidden;
  padding: 8px 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layout {
  margin: 0 auto;
  max-width: 1180px;
  padding: 14px 12px 28px;
}

.status-panel {
  background: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
  display: block;
  margin-bottom: 12px;
  padding: 16px;
}

.status-panel h2 {
  color: var(--blue-950);
  font-size: 1.55rem;
  line-height: 1.08;
  margin-bottom: 7px;
}

.status-panel p:last-child {
  color: var(--muted);
  line-height: 1.42;
  margin-bottom: 0;
}

.primary,
.secondary,
.ghost-button {
  border: 0;
  border-radius: 8px;
  font-weight: 850;
  min-height: 48px;
  padding: 0 16px;
}

.primary {
  background: linear-gradient(180deg, #e64943 0%, var(--red) 100%);
  box-shadow: 0 8px 18px rgba(216, 59, 53, 0.25);
  color: var(--white);
}

.secondary {
  background: var(--blue-gray-strong);
  color: var(--blue-900);
}

.ghost-button {
  background: var(--blue-gray);
  color: var(--blue-900);
}

.workspace-grid {
  align-items: start;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

.map-panel,
.panel {
  background: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
}

.map-panel {
  overflow: hidden;
}

.map-toolbar,
.panel-header {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 14px;
}

.map-toolbar h3,
.panel h3 {
  color: var(--blue-950);
  font-size: 1.18rem;
  line-height: 1.16;
  margin-bottom: 0;
}

.map {
  background: #dcebf1;
  height: 44vh;
  min-height: 280px;
  width: 100%;
}

.map-help {
  border-top: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.38;
  margin: 0;
  padding: 12px 14px 14px;
}

.side-panel {
  display: grid;
  gap: 12px;
}

.panel {
  padding-bottom: 14px;
}

.panel .form-stack {
  padding: 0 14px;
}

.stops-list {
  display: grid;
  gap: 10px;
  max-height: none;
  overflow: visible;
  padding: 0 14px;
}

.stop-item {
  background: #fbfdfe;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
}

.stop-item.selected {
  border-color: rgba(36, 106, 159, 0.55);
  box-shadow: inset 4px 0 0 var(--blue-700);
}

.stop-item strong {
  color: var(--blue-950);
  display: block;
  margin-bottom: 4px;
}

.stop-item span {
  color: var(--muted);
  display: block;
  font-size: 0.92rem;
  line-height: 1.35;
}

.selected-label {
  background: #e8f1f8;
  border-radius: 999px;
  color: var(--blue-700) !important;
  display: inline-block !important;
  font-size: 0.82rem !important;
  font-weight: 850;
  margin-top: 8px;
  padding: 6px 10px;
  width: fit-content;
}

.stop-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
  margin-top: 11px;
}

.stop-actions button {
  background: var(--blue-gray);
  border: 0;
  border-radius: 8px;
  color: var(--blue-900);
  font-weight: 850;
  min-height: 40px;
  padding: 0 12px;
}

.stop-actions button:last-child {
  background: var(--blue-gray-strong);
}

.marker-dot {
  align-items: center;
  border: 3px solid var(--white);
  border-radius: 50%;
  box-shadow: 0 4px 14px rgba(16, 44, 74, 0.26);
  color: var(--white);
  display: grid;
  font-size: 0.75rem;
  font-weight: 900;
  height: 30px;
  justify-content: center;
  width: 30px;
}

.marker-stop {
  background: var(--blue-700);
}

.marker-school {
  background: var(--green);
}

.marker-vehicle {
  background: var(--red);
}

.adding-mode .map {
  outline: 4px solid rgba(216, 59, 53, 0.32);
  outline-offset: -4px;
}

.maplibregl-popup-content {
  border-radius: 8px;
  color: var(--ink);
  font: 14px Arial, Helvetica, sans-serif;
}

.map-fallback {
  align-items: center;
  color: var(--muted);
  display: grid;
  font-weight: 800;
  height: 100%;
  justify-content: center;
  line-height: 1.4;
  padding: 22px;
  text-align: center;
}

.role-actions {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.action-card {
  background: var(--blue-gray);
  border: 1px solid var(--blue-gray-strong);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  padding: 12px;
}

.action-card strong {
  color: var(--blue-950);
  display: block;
  line-height: 1.2;
}

.action-card span {
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.35;
}

.request-row {
  align-items: center;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr auto;
  padding-top: 10px;
}

.request-row button {
  background: var(--blue-700);
  border: 0;
  border-radius: 8px;
  color: var(--white);
  font-weight: 850;
  min-height: 38px;
  padding: 0 12px;
}

@media (min-width: 720px) {
  .auth-card {
    padding: 28px;
  }

  .layout {
    padding: 20px 22px 36px;
  }

  .workspace-grid {
    grid-template-columns: minmax(0, 1.15fr) minmax(330px, 0.85fr);
  }

  .map {
    height: min(58vh, 620px);
    min-height: 420px;
  }
}

@media (max-width: 430px) {
  .auth-screen {
    align-items: stretch;
    padding: 12px;
  }

  .auth-card {
    align-self: center;
    padding: 18px;
  }

  .brand-logo-large {
    width: 290px;
  }

  .topbar {
    padding: 10px 12px;
  }

  .brand-logo-small {
    width: 134px;
  }

  .user-chip span {
    max-width: 118px;
  }

  .map-toolbar,
  .panel-header {
    flex-direction: column;
  }

  .map-toolbar .secondary,
  .panel-header .status {
    width: 100%;
  }
}
