html {
  font-size: 80%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  background-color: #f8f9fa;
  color: #333;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background-color: #632ca6;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

.main-container {
  margin-left: 70px;
  width: calc(100% - 70px);
  transition: margin-left 0.3s, width 0.3s;
  padding: 0;
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.datadog-sidebar.expanded ~ .main-container,
.datadog-sidebar.expanded ~ #footer {
  margin-left: 230px;
  width: calc(100% - 230px);
}

.datadog-sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: 70px;
  background-color: #1a1b24;
  color: #a3a5ad;
  z-index: 1000;
  transition: width 0.3s ease, transform 0.3s ease;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.datadog-sidebar.expanded {
  width: 230px;
}

.sidebar-logo {
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid #2d2f3b;
  margin-bottom: 15px;
}

.sidebar-brand {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  opacity: 0;
  height: 0;
  overflow: hidden;
  transition: opacity 0.3s ease;
}

.datadog-sidebar.expanded .sidebar-brand {
  opacity: 1;
  height: auto;
}

.sidebar-nav {
  flex: 1;
  list-style: none;
  padding: 0 0 56px;
  margin: 0;
  overflow-y: auto;
}

.nav-item {
  position: relative;
}

.nav-divider {
  height: 1px;
  background-color: #2d2f3b;
  margin: 8px 16px;
  list-style: none;
}

.sidebar-nav .nav-link {
  padding: 8px 16px;
  color: #a3a5ad;
  display: flex;
  align-items: center;
  text-decoration: none;
  white-space: nowrap;
  font-size: 14px;
}

.sidebar-nav .nav-link i {
  font-size: 16px;
  width: 36px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-nav .nav-link span {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.datadog-sidebar.expanded .sidebar-nav .nav-link span {
  opacity: 1;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
  color: #fff;
  background-color: #2d2f3b;
}

.sidebar-nav .nav-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background-color: #632ca6;
}

.sidebar-toggle {
  position: absolute;
  bottom: 15px;
  right: 15px;
  width: 30px;
  height: 30px;
  background-color: #1a1b24;
  border: 1px solid #2d2f3b;
  border-radius: 50%;
  color: #a3a5ad;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  z-index: 1001;
}

.sidebar-toggle:hover {
  color: #fff;
  background-color: #2d2f3b;
}

#footer {
  margin-left: 70px;
  width: calc(100% - 70px);
  transition: margin-left 0.3s, width 0.3s;
  padding: 1rem;
  text-align: center;
  color: #8e9194;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
  padding: 0 16px;
  background-color: #fff;
  border-bottom: 1px solid #e6e6e6;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-heading {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.page-title {
  font-size: 18px;
  font-weight: 600;
  color: #555;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.account-menu {
  position: relative;
  margin-left: auto;
  flex-shrink: 0;
}

.account-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: #333;
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  max-width: 100%;
  min-height: 44px;
}

.account-trigger:hover,
.account-menu:focus-within .account-trigger,
.account-menu.open .account-trigger {
  background-color: #f8f9fa;
}

.account-avatar {
  display: inline-flex;
  width: 28px;
  height: 28px;
}

.account-picture[hidden] {
  display: none !important;
}

.account-fallback {
  background-color: #632ca6;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

.account-identity {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  max-width: 46vw;
}

.account-name,
.account-popover-name {
  font-weight: 600;
  color: #333;
}

.account-name,
.account-project {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-project {
  color: #666;
  font-size: 12px;
  font-weight: 500;
}

.account-project i {
  font-size: 10px;
}

.account-popover-name {
  overflow-wrap: anywhere;
}

.account-popover {
  display: none;
  position: absolute;
  top: calc(100% - 2px);
  right: 0;
  width: min(300px, calc(100vw - 24px));
  max-height: min(70vh, 480px);
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 12px;
  z-index: 30;
}

.account-popover::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 0;
  right: 0;
  height: 10px;
}

.account-menu:focus-within .account-popover,
.account-menu.open .account-popover {
  display: block;
}

@media (hover: hover) and (pointer: fine) {
  .account-menu:hover .account-popover {
    display: block;
  }
}

.account-popover-role {
  color: #632ca6;
  font-weight: 600;
  margin: 4px 0 12px;
}

.account-projects {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.project-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  min-height: 44px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 8px;
  text-align: left;
  color: #333;
}

.project-option-name {
  font-weight: 600;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-option-role {
  color: #632ca6;
  font-size: 12px;
  font-weight: 600;
}

.project-option:hover,
.project-option:focus-visible,
.project-option.is-current {
  background: #f3eefe;
}

.account-link,
.account-logout {
  display: flex;
  align-items: center;
  min-height: 44px;
  color: #333;
  text-decoration: none;
  padding: 8px;
  border-radius: 8px;
}

.account-logout {
  border-top: 1px solid #e6e6e6;
  border-radius: 0;
  margin-top: 4px;
}

.account-link:hover,
.account-logout:hover,
.account-link:focus-visible,
.account-logout:focus-visible {
  color: #632ca6;
  background: #f8f9fa;
}

.page-alert {
  margin-bottom: 12px;
}

.people-card + .people-card {
  margin-top: 12px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 12px;
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stack-form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.stack-form-row input,
.stack-form-row select,
.person-actions select {
  min-height: 44px;
  border: 1px solid #d9d9d9;
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: #333;
}

.stack-form-row input,
.stack-form-row select {
  flex: 1 1 180px;
  min-width: 0;
}

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

.person {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-top: 1px solid #e6e6e6;
}

.person-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 180px;
}

.person-email,
.person-note,
.project-id {
  color: #666;
  overflow-wrap: anywhere;
}

.project-id {
  margin: 12px 0 0;
  font-size: 13px;
}

.site-meta {
  margin: 0;
}

.site-meta div {
  display: grid;
  gap: 4px;
}

.site-meta dt {
  margin: 0;
  color: #666;
  font-size: 13px;
  font-weight: 600;
}

.site-meta dd {
  margin: 0;
}

.site-meta code {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.welcome-card .site-meta {
  margin-top: 16px;
}

.person-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.person-actions form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.role-lock {
  color: #632ca6;
  font-weight: 600;
}

.welcome-message + .welcome-message {
  margin-top: 8px;
}

.map-workspace {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 12px;
  min-height: calc(100vh - 160px);
}

.map-panel,
.map-canvas {
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 10px;
}

.map-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px;
  gap: 10px;
}

.map-canvas {
  min-height: 50vh;
  z-index: 1;
}

.map-toolbar,
.map-actions,
.plan-rows label {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.map-field-picker,
.map-editor label,
.plan-rows li {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 600;
}

.map-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.map-editor input,
.map-editor select,
.map-editor textarea,
.map-field-picker select {
  min-height: 44px;
  border: 1px solid #d9d9d9;
  border-radius: 8px;
  padding: 8px 10px;
  font-weight: 400;
  font-size: 16px;
}

.map-list,
.plan-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
}

.map-list-button,
.plan-rows button {
  width: 100%;
  min-height: 44px;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 8px;
}

.map-list-button.is-current,
.map-list-button:hover,
.plan-rows button:hover {
  background: #f3eefe;
}

.plan-rows li {
  padding: 8px 0;
  border-top: 1px solid #e6e6e6;
}

.map-status,
.map-hint {
  margin: 0;
  color: #666;
  font-weight: 400;
}

.page-body {
  padding: 20px 15px;
}

.welcome-card {
  border: 1px solid #e6e6e6;
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.welcome-message {
  margin: 0;
  font-size: 16px;
  color: #333;
}

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f8f9fa;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  border: 1px solid #e6e6e6;
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.login-card .card-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 28px;
}

.login-card h1 {
  font-size: 22px;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.login-lead {
  margin: 0;
  color: #555;
}

.login-card .alert {
  width: 100%;
  margin: 0;
}

.btn-pharos {
  background-color: #632ca6;
  border-color: #632ca6;
  color: #fff;
}

.btn-pharos:hover,
.btn-pharos:focus {
  background-color: #52248c;
  border-color: #52248c;
  color: #fff;
}

.login-card .btn-pharos {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

@media (max-width: 768px) {
  .main-container,
  #footer,
  .datadog-sidebar.expanded ~ .main-container,
  .datadog-sidebar.expanded ~ #footer {
    margin-left: 0;
    width: 100%;
  }

  .page-body {
    padding: 16px 10px;
  }

  .topbar {
    align-items: flex-start;
    padding-top: 10px;
    padding-bottom: 10px;
    padding-left: max(72px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .page-title {
    max-width: 34vw;
    font-size: 16px;
  }

  .account-popover {
    width: min(300px, calc(100vw - 76px));
  }

  .stack-form-row,
  .person-actions,
  .person-actions form {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .stack-form-row input,
  .stack-form-row select,
  .stack-form-row .btn,
  .person-actions select,
  .person-actions .btn {
    width: 100%;
    min-height: 44px;
    font-size: 16px;
  }

  .login-card .btn-pharos {
    width: 100%;
    justify-content: center;
  }

  .map-workspace {
    grid-template-columns: 1fr;
  }

  .map-canvas {
    min-height: 60vh;
    order: -1;
  }

  .map-actions,
  .map-actions .btn,
  .map-toolbar .btn {
    width: 100%;
  }

  #footer {
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }

  .datadog-sidebar {
    transform: translateX(-100%);
    width: 250px;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
  }

  .datadog-sidebar.mobile-visible {
    transform: translateX(0);
  }

  .datadog-sidebar.expanded {
    width: 250px;
  }

  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }

  .sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
  }

  .mobile-menu-btn {
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
    width: 44px;
    height: 44px;
    background-color: #1a1b24;
    border: 1px solid #2d2f3b;
    border-radius: 8px;
    color: #a3a5ad;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 1002;
    font-size: 18px;
  }

  .sidebar-toggle {
    display: none;
  }
}

.robot-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
  background-color: #c0392b;
}

.robot-dot.is-alive {
  background-color: #2ecc71;
}

.robot-dot.is-stale {
  background-color: #c0392b;
}

.robot-topic {
  color: #888;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-wrap: anywhere;
}

.robot-credentials-warning {
  margin: 0 0 12px;
  color: #a15c00;
  font-weight: 600;
}

.home-map {
  height: 420px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #e6e6e6;
}

.home-robot-popup {
  font-size: 13px;
  line-height: 1.5;
}

.home-robot-popup strong {
  display: block;
  margin-bottom: 4px;
}

.home-no-location {
  margin-top: 12px;
  color: #666;
}
