:root {
  color-scheme: dark;
  --bg: #111214;
  --panel: #1d1f23;
  --panel-2: #272a30;
  --line: #3a3f47;
  --text: #f4efe6;
  --muted: #b8b0a2;
  --accent: #d5b76d;
  --accent-2: #5ab6a7;
  --danger: #e36f5d;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  background: linear-gradient(180deg, #202227, #17191d);
  border-right: 1px solid var(--line);
  overflow: auto;
  scrollbar-gutter: stable;
}

.brand-block h1 {
  margin: 0 0 10px;
  font-size: 34px;
  line-height: 1;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin: 0;
  padding: 5px 10px;
  border: 1px solid var(--line);
  background: #15171a;
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
}

.status-pill.live {
  color: #dffaf3;
  border-color: rgba(90, 182, 167, 0.5);
  background: rgba(90, 182, 167, 0.13);
}

.profile-panel {
  border-color: rgba(90, 182, 167, 0.28);
}

.hidden {
  display: none !important;
}

.panel {
  min-width: 0;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 0;
  font-size: 15px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-body {
  min-width: 0;
  margin-top: 12px;
}

.panel-collapse-button {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: var(--text);
  background: rgba(18, 20, 24, 0.85);
  cursor: pointer;
  transition: transform 140ms ease;
}

.panel.collapsed {
  box-shadow: none;
}

.panel.collapsed .panel-collapse-button {
  transform: rotate(-90deg);
}

.panel.shake {
  animation: panel-shake 420ms ease-in-out;
  border-color: rgba(227, 111, 93, 0.75);
}

@keyframes panel-shake {
  0%,
  100% {
    transform: translateX(0);
  }

  20%,
  60% {
    transform: translateX(-7px);
  }

  40%,
  80% {
    transform: translateX(7px);
  }
}

.filter-list,
.online-list {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.category-block {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px 30px 30px;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 8px;
  background: var(--panel-2);
  border: 1px solid transparent;
  border-radius: 7px;
  overflow: hidden;
}

.filter-toggle {
  display: flex;
  align-items: center;
  min-width: 0;
  flex: 1;
  gap: 10px;
  cursor: pointer;
}

.filter-row input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  accent-color: var(--accent-2);
}

.category-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-edit-button,
.category-delete-button,
.category-expand-button {
  flex: 0 0 auto;
  width: 100%;
  min-width: 0;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: var(--text);
  background: rgba(18, 20, 24, 0.85);
  cursor: pointer;
  transition: transform 140ms ease;
}

.category-edit-button {
  padding: 0;
  color: var(--muted);
  font-size: 12px;
}

.category-delete-button {
  color: #fff6f3;
  background: rgba(227, 111, 93, 0.16);
  border-color: rgba(227, 111, 93, 0.38);
}

.category-delete-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.category-expand-button.expanded {
  transform: rotate(180deg);
}

.category-entities {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 2px 8px 4px 28px;
  overflow: hidden;
}

.entity-group-heading {
  margin-top: 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.entity-button {
  min-width: 0;
  width: auto;
  min-height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 6px;
  padding: 5px 8px;
  color: var(--muted);
  background: rgba(18, 20, 24, 0.72);
  cursor: pointer;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entity-button:hover {
  color: var(--text);
  border-color: rgba(213, 183, 109, 0.4);
}

.entity-button.route-entity {
  color: #d9fbff;
  border-color: rgba(88, 199, 214, 0.28);
}

.empty-entities {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.marker-form {
  display: grid;
  gap: 11px;
}

.marker-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.marker-form input,
.marker-form select,
.marker-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  color: var(--text);
  background: #121418;
}

.marker-form input[type="color"] {
  min-height: 42px;
  padding: 4px;
}

.tool-mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.workspace-mode-toggle,
.workspace-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}

.display-name-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(80px, 0.65fr);
  align-items: center;
  gap: 6px;
}

.display-at {
  color: var(--accent);
  font-weight: 800;
}

.checkbox-row {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 8px !important;
}

.checkbox-row input {
  width: auto;
}

.workspace-actions .icon-text-button,
.workspace-actions .primary-button,
.workspace-actions .danger-button {
  min-width: 0;
  min-height: 36px;
  padding-inline: 8px;
}

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

.admin-controls {
  display: grid;
  gap: 10px;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.admin-controls h3 {
  margin: 0;
  color: var(--accent);
  font-size: 13px;
}

.mode-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: var(--panel-2);
  cursor: pointer;
}

.mode-button.active {
  color: #15120b;
  border-color: transparent;
  background: var(--accent);
  font-weight: 800;
  -webkit-text-stroke: 0.45px #ffffff;
  text-shadow: 0 0 0 #ffffff, 0 1px 0 rgba(255, 255, 255, 0.72);
}

.map-tools-overlay {
  position: absolute;
  z-index: 8;
  top: 16px;
  left: 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(92px, 1fr));
  gap: 8px;
  width: min(230px, calc(100% - 32px));
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(20, 22, 25, 0.88);
  box-shadow: var(--shadow);
  cursor: move;
  touch-action: none;
}

.map-tools-overlay .mode-button {
  min-height: 36px;
  background: rgba(39, 42, 48, 0.94);
  cursor: pointer;
}

.map-tools-overlay.dragging {
  cursor: grabbing;
}

.tool-readout {
  margin-top: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: #121418;
  font-size: 13px;
  line-height: 1.35;
}

.wide-button {
  width: 100%;
  min-height: 36px;
  margin-top: 8px;
}

.primary-button,
.icon-text-button,
.danger-button {
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}

.primary-button {
  min-height: 40px;
  color: #15120b;
  background: var(--accent);
  font-weight: 800;
}

.icon-text-button {
  padding: 7px 9px;
  color: var(--text);
  background: var(--panel-2);
}

.danger-button {
  min-height: 38px;
  color: #fff6f3;
  background: rgba(227, 111, 93, 0.24);
  border: 1px solid rgba(227, 111, 93, 0.45);
}

.danger-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.entity-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px 44px 30px;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

.entity-row-no-lock {
  grid-template-columns: minmax(0, 1fr) 44px 30px;
}

.trash-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
}

.entity-delete-button,
.entity-edit-button,
.entity-lock-button,
.trash-action-button {
  min-height: 30px;
  border: 1px solid rgba(227, 111, 93, 0.38);
  border-radius: 6px;
  color: #fff6f3;
  background: rgba(227, 111, 93, 0.16);
  cursor: pointer;
}

.entity-delete-button,
.entity-edit-button,
.entity-lock-button {
  width: 100%;
  min-width: 0;
}

.trash-action-button {
  min-width: 30px;
}

.entity-edit-button {
  color: var(--text);
  border-color: rgba(213, 183, 109, 0.35);
  background: rgba(213, 183, 109, 0.14);
  font-size: 12px;
}

.entity-edit-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.entity-lock-button {
  color: #dffaf7;
  border-color: rgba(90, 182, 167, 0.36);
  background: rgba(90, 182, 167, 0.14);
  font-size: 12px;
}

.entity-lock-button.locked {
  color: #fff6f3;
  border-color: rgba(227, 111, 93, 0.46);
  background: rgba(227, 111, 93, 0.22);
}

.trash-bin {
  display: grid;
  gap: 12px;
}

.trash-group {
  display: grid;
  gap: 6px;
}

.trash-group h3 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.trash-name {
  min-width: 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trash-actions {
  display: flex;
  gap: 5px;
}

.user-chip {
  padding: 8px 10px;
  background: var(--panel-2);
  border-radius: 7px;
  color: var(--muted);
  font-size: 13px;
}

.map-stage {
  position: relative;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  background: #0c0d0f;
}

.viewer,
.marker-layer,
.route-layer {
  position: absolute;
  inset: 0;
}

.marker-layer {
  pointer-events: none;
  z-index: 4;
}

.route-layer {
  z-index: 5;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.route-layer.drawing {
  pointer-events: auto;
  cursor: crosshair;
}

.map-stage.right-panning,
.route-layer.right-panning {
  cursor: grabbing;
}

.route-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
  paint-order: stroke;
}

.saved-route {
  stroke: var(--route-color, #58c7d6);
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.55));
}

.saved-drawing {
  stroke: var(--route-color, #f2d15f);
  stroke-width: 5;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.55));
}

.draft-route {
  stroke: #f4efe6;
  stroke-dasharray: 8 8;
}

.draft-drawing {
  stroke: var(--route-color, #f2d15f);
  stroke-dasharray: 5 6;
}

.planner-route {
  stroke: #d5b76d;
  stroke-dasharray: 3 7;
}

.measure-route {
  stroke: #e36f5d;
  stroke-dasharray: 10 5;
}

.route-point {
  fill: #111214;
  stroke: #f4efe6;
  stroke-width: 2;
}

.route-label {
  fill: #f4efe6;
  stroke: rgba(0, 0, 0, 0.8);
  stroke-width: 3;
  paint-order: stroke;
  font-size: 12px;
  font-weight: 800;
}

.route-segment-note {
  fill: #f4efe6;
  stroke: rgba(0, 0, 0, 0.82);
  stroke-width: 3;
  paint-order: stroke;
  font-size: 11px;
  font-weight: 700;
}

.scale-bar {
  position: absolute;
  z-index: 9;
  left: 18px;
  bottom: 18px;
  min-width: 96px;
  padding: 8px 10px 7px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  color: var(--text);
  background: rgba(15, 16, 18, 0.82);
  box-shadow: var(--shadow);
  pointer-events: none;
}

.scale-line {
  height: 10px;
  border-left: 2px solid var(--text);
  border-right: 2px solid var(--text);
  border-bottom: 2px solid var(--text);
}

.scale-label {
  margin-top: 4px;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.scale-bar.unavailable {
  opacity: 0.72;
}

.scale-bar.unavailable .scale-line {
  border-color: var(--muted);
}

.scale-bar.unavailable .scale-label {
  color: var(--muted);
  font-weight: 700;
}

.map-toolbar {
  position: absolute;
  z-index: 8;
  top: 16px;
  right: 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 360px;
  gap: 8px;
}

.workspace-overlay,
.group-overlay {
  position: absolute;
  z-index: 10;
  top: 70px;
  right: 16px;
  width: min(380px, calc(100% - 32px));
  max-height: calc(100vh - 96px);
  min-width: 0;
}

.workspace-overlay .profile-panel,
.group-overlay .profile-panel {
  background: rgba(29, 31, 35, 0.96);
  max-height: inherit;
  overflow: hidden;
}

.workspace-overlay .marker-form,
.group-overlay .marker-form {
  min-width: 0;
  max-height: calc(100vh - 170px);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
}

.workspace-overlay .panel-heading,
.group-overlay .panel-heading {
  cursor: grab;
}

.workspace-overlay.dragging .panel-heading,
.group-overlay.dragging .panel-heading {
  cursor: grabbing;
}

.group-overlay {
  right: 74px;
  width: min(560px, calc(100% - 32px));
}

.tool-button {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  color: var(--text);
  background: rgba(20, 22, 25, 0.88);
  cursor: pointer;
  box-shadow: var(--shadow);
  font-size: 20px;
  font-weight: 800;
}

.tool-button.active,
.key-tool-button.active {
  color: #15120b;
  border-color: var(--accent);
  background: var(--accent);
}

.key-tool-button {
  width: auto;
  min-width: 42px;
  padding: 0 10px;
  font-size: 13px;
}

.group-tool-button {
  width: auto;
  min-width: 42px;
  padding: 0 10px;
  font-size: 18px;
}

.workspace-tool-button {
  width: auto;
  min-width: 58px;
  padding: 0 10px;
  font-size: 12px;
}

.advanced-details {
  display: grid;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(10, 11, 13, 0.42);
}

.advanced-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.nested-details {
  margin-top: 6px;
}

.debug-admin-block {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.role-selection-label {
  margin-top: 8px;
  margin-bottom: 10px;
}

.group-members-list {
  display: grid;
  gap: 8px;
}

.group-member-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(72px, 0.45fr) minmax(96px, 0.62fr);
  gap: 6px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  min-width: 0;
}

.group-member-row .trash-action-button,
.group-member-row .danger-button {
  min-height: 30px;
}

.permission-matrix {
  display: grid;
  gap: 8px;
}

.permission-row {
  display: grid;
  grid-template-columns: minmax(78px, 1fr) repeat(5, minmax(44px, 0.55fr));
  gap: 6px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(10, 11, 13, 0.38);
  min-width: 0;
}

.permission-check {
  display: grid;
  justify-items: center;
  gap: 3px;
  align-items: center;
  min-width: 0;
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  line-height: 1.1;
}

.group-member-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.group-member-meta {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.group-member-row select,
.group-member-row button {
  min-width: 0;
  width: 100%;
}

@media (max-width: 720px) {
  .group-member-row {
    grid-template-columns: 1fr;
  }

  .permission-row {
    grid-template-columns: 1fr repeat(5, minmax(38px, 1fr));
  }
}

.group-member-row.inactive {
  opacity: 0.62;
}

.identity-blocked {
  outline: 2px solid rgba(227, 111, 93, 0.8);
}

.reset-tool-button {
  width: auto;
  padding: 0 12px;
  font-size: 13px;
}

.viewing-counter {
  position: absolute;
  z-index: 9;
  right: 18px;
  bottom: 18px;
  min-height: 32px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  color: var(--text);
  background: rgba(15, 16, 18, 0.82);
  box-shadow: var(--shadow);
  pointer-events: none;
  font-size: 13px;
  font-weight: 800;
}

.map-marker {
  position: absolute;
  width: 28px;
  height: 28px;
  transform: translate(-50%, -50%) rotate(-45deg);
  border: 2px solid rgba(255, 255, 255, 0.82);
  border-radius: 999px 999px 999px 4px;
  pointer-events: auto;
  cursor: grab;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}

.map-marker::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
}

.map-marker:active {
  cursor: grabbing;
}

.map-marker.pulse {
  animation: marker-pulse 900ms ease-out;
}

@keyframes marker-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(213, 183, 109, 0.8), 0 8px 20px rgba(0, 0, 0, 0.45);
  }

  100% {
    box-shadow: 0 0 0 20px rgba(213, 183, 109, 0), 0 8px 20px rgba(0, 0, 0, 0.45);
  }
}

.map-marker.hidden {
  display: none;
}

.marker-label {
  position: absolute;
  left: 18px;
  top: -3px;
  min-width: 90px;
  max-width: 180px;
  padding: 4px 7px;
  border-radius: 6px;
  transform: rotate(45deg);
  color: var(--text);
  background: rgba(15, 16, 18, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.openseadragon-container {
  background: #0c0d0f !important;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 42vh 58vh;
  }

  .sidebar {
    height: 42vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .map-stage {
    height: 58vh;
  }
}
