/* Alstergee Designer - Main Styles */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Dark theme (default) */
  --bg: #0a0e12;
  --bg-secondary: #12181f;
  --card: #1a2129;
  --border: #252d38;
  --text: #e0e6ed;
  --text-muted: #6b7a8a;
  --primary: #3b82f6;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f97316;

  /* Category colors */
  --cat-network: #3b82f6;
  --cat-camera: #22c55e;
  --cat-fire: #ef4444;
  --cat-audio: #f97316;
  --cat-security: #8b5cf6;
  --cat-signage: #ec4899;
  --cat-power: #eab308;
  --cat-lighting: #f59e0b;
  --cat-door: #14b8a6;
  --cat-video: #6366f1;

  /* Sizes */
  --header-height: 120px; /* 2 rows of toolbar buttons */
  --sidebar-width: 360px;
}

/* Light theme */
[data-theme="light"] {
  --bg: #f5f7fa;
  --bg-secondary: #ffffff;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1a202c;
  --text-muted: #718096;
}

/* Hide mobile-only elements on desktop */
.mobile-only,
.mobile-menu-btn,
.mobile-menu,
.mobile-brand,
.mobile-floor-select,
.mobile-ruler-btn,
.mobile-size-slider,
.header-mobile {
  display: none !important;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
}

/* Header - Two Row Layout */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: var(--header-height);
}

.header-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 16px;
  flex-wrap: nowrap;
}

.header-row > * {
  flex-shrink: 0;
}

.header-row .btn {
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.header-row-1 {
  border-bottom: 1px solid var(--border);
}

.header-row-2 {
  background: var(--bg);
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}

header h1 {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  margin: 0;
  line-height: 32px;
}

/* Search popup */
.search-popup {
  display: none;
  position: absolute;
  top: 100%;
  right: 200px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.search-popup.visible {
  display: block;
}

.search-popup input {
  width: 250px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 13px;
}

.search-results {
  display: none;
  max-height: 300px;
  overflow-y: auto;
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 13px;
}

.search-result-item:hover {
  background: var(--bg);
}

.search-result-item.no-results,
.search-result-item.more {
  color: var(--text-muted);
  cursor: default;
  font-style: italic;
}

.search-result-item .result-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.search-result-item .result-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-item .result-name mark {
  background: var(--warning);
  color: var(--bg);
  padding: 0 2px;
  border-radius: 2px;
}

.search-result-item .result-floor {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Icon-only button */
.btn-icon {
  padding: 6px 8px !important;
  min-width: auto;
}

.btn-primary {
  background: var(--primary) !important;
  color: white !important;
}

/* Project selector */
.project-select {
  display: flex;
  gap: 4px;
  align-items: center;
  margin: 0;
  padding: 0;
}

.project-select select {
  padding: 6px 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  min-width: 140px;
  margin: 0;
  vertical-align: middle;
  height: 32px;
}

.project-select .btn {
  height: 32px;
  margin: 0;
}

/* Sync status indicator */
.sync-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  margin-left: 4px;
  transition: background 0.3s;
}

.sync-status.saving {
  background: var(--warning);
  animation: pulse 1s infinite;
}

.sync-status.error {
  background: var(--danger);
}

.sync-status.offline {
  background: var(--text-muted);
}

.sync-status.queued {
  background: var(--warning);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--warning);
}

.sync-status.syncing {
  background: var(--primary);
  animation: pulse 0.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Floor tabs */
.floor-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg);
  padding: 2px;
  border-radius: 6px;
  height: 32px;
  align-items: center;
}

.floor-tab {
  padding: 6px 12px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  font-size: 11px;
  transition: all 0.15s;
}

.floor-tab:hover {
  color: var(--text);
}

.floor-tab.active {
  background: var(--border);
  color: var(--text);
}

.floor-tab.add-floor {
  color: var(--primary);
  font-weight: 600;
}

/* Floor tab drag-and-drop */
.floor-tab.dragging {
  opacity: 0.5;
  background: var(--primary);
}

.floor-tab.drag-over {
  border-left: 2px solid var(--primary);
  padding-left: 10px;
}

.floor-tab[draggable="true"] {
  cursor: grab;
}

.floor-tab[draggable="true"]:active {
  cursor: grabbing;
}

/* Filters */
.filters {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.filter-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card);
  cursor: pointer;
  font-size: 10px;
  color: var(--text-muted);
  transition: all 0.15s;
}

.filter-btn:hover {
  border-color: var(--text-muted);
}

.filter-btn.active {
  border-color: currentColor;
  color: var(--text);
}

.filter-btn.off {
  opacity: 0.3;
}

.filter-btn .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

/* Search */
.search-box {
  position: relative;
}

.search-box input {
  padding: 6px 10px;
  padding-left: 28px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
  width: 160px;
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary);
}

.search-box::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  background: var(--text-muted);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
}

/* Size control */
.size-control {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--text-muted);
  height: 32px;
}

.size-control input[type="range"] {
  width: 60px;
  cursor: pointer;
}

/* Toolbar buttons */
.toolbar-buttons {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

/* Buttons */
.btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.btn.primary:hover {
  opacity: 0.9;
}

.btn svg {
  display: block;
  flex-shrink: 0;
}

.btn.danger {
  color: var(--danger);
}

.btn.danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

.btn-small {
  padding: 4px 8px;
  font-size: 10px;
}

.zoom-level {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 40px;
  text-align: center;
}

/* Main content */
main {
  margin-top: var(--header-height);
  height: calc(100vh - var(--header-height));
  display: flex;
}

/* Map container */
.map-container {
  flex: 1;
  overflow: auto;
  padding: 16px;
  position: relative;
}

.map-box {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 400px;
  overflow: hidden;
  touch-action: none; /* Prevent browser touch handling - JS controls gestures */
}

.floor-image {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none; /* Prevent browser touch handling */
}

.floor-image.hidden {
  display: none;
}

/* Transforms (zoom/rotation) */
.floor-image,
.markers-layer,
.coverage-layer {
  transform-origin: center center;
  transition: transform 0.2s ease;
}

/* Disable transitions during gesture to prevent "loop around" animation bug */
/* CSS transitions animate the "long way" when going from e.g. 10deg to 350deg */
.gesturing .floor-image,
.gesturing .markers-layer,
.gesturing .coverage-layer {
  transition: none !important;
}

.map-box.rotated {
  /* For 90/270 rotation, we need to adjust for the dimension swap */
}

.map-box.rotated .floor-image,
.map-box.rotated .markers-layer,
.map-box.rotated .coverage-layer {
  /* Allow rotated content to maintain proper positioning */
}

/* Upload prompt */
.upload-prompt {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  cursor: pointer;
  border: 2px dashed var(--border);
  border-radius: 8px;
  margin: 20px;
  transition: all 0.2s;
}

.upload-prompt:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.upload-prompt.hidden {
  display: none;
}

.upload-prompt .upload-icon {
  font-size: 48px;
  font-weight: 300;
}

/* Layers */
.markers-layer,
.coverage-layer {
  position: absolute;
  top: 0;
  left: 0;
  /* Size set by JavaScript to match floor-image exactly */
  pointer-events: none;
}

.coverage-layer {
  z-index: 1;
}

.markers-layer {
  z-index: 2;
}

.ruler-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 3; /* Above markers-layer (z-index: 2) when active */
}

.markers-layer {
  pointer-events: auto;
  touch-action: none; /* Prevent browser touch handling */
}

/* Marker base styles */
.marker {
  position: absolute;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  color: white;
  user-select: none;
}

.marker:hover {
  z-index: 100;
}

/* Single selection - subtle ring */
.marker.selected {
  box-shadow: 0 0 0 3px var(--primary), 0 2px 8px rgba(0,0,0,0.4);
  z-index: 101;
}

/* Multi-selection - scale up 3% + colored ring */
.marker.multi-selected {
  transform: translate(-50%, -50%) scale(1.03);
  box-shadow: 0 0 0 3px var(--warning), 0 2px 8px rgba(0,0,0,0.4);
  z-index: 99;
}

/* Search match - subtle ring on matching markers */
.marker.search-match {
  box-shadow: 0 0 0 2px var(--success), 0 2px 6px rgba(0,0,0,0.3);
}

/* Search highlight animation (when jumping to marker) */
.marker.search-highlight {
  animation: searchPulse 0.5s ease-out 3;
}

@keyframes searchPulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--primary), 0 2px 8px rgba(0,0,0,0.4); }
  50% { box-shadow: 0 0 0 8px var(--primary), 0 0 20px rgba(59, 130, 246, 0.5); }
}

/* Selection box for multi-select (shift+drag) */
.selection-box {
  position: absolute;
  border: 2px dashed var(--warning);
  background: rgba(245, 158, 11, 0.1);
  pointer-events: none;
  z-index: 150;
  display: none;
}

.ruler-layer.active {
  pointer-events: auto;
  cursor: crosshair;
  touch-action: none; /* Enable JS touch handling for ruler */
}

/* Disable marker interactions when in ruler mode */
.map-box.ruler-mode .markers-layer {
  pointer-events: none;
}

.map-box.ruler-mode .marker {
  pointer-events: none;
}

/* Measurement Layer */
.measurement-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.measurement-layer.active {
  pointer-events: auto;
  cursor: crosshair;
}

.measure-line {
  stroke: var(--warning);
  stroke-width: 2;
  stroke-dasharray: 6 3;
}

.measure-point {
  fill: var(--warning);
  stroke: white;
  stroke-width: 2;
  pointer-events: auto;
}

.measure-point.draggable {
  cursor: move;
}

.measure-point.draggable:hover {
  fill: #fb923c;
  transform-origin: center;
  r: 10;
}

.measure-point.pending {
  fill: var(--primary);
  animation: pulse 1s ease-in-out infinite;
}

.measure-label-bg {
  fill: var(--card);
  stroke: var(--border);
  stroke-width: 1;
}

.measure-label {
  fill: var(--text);
  font-size: 12px;
  font-weight: 600;
  font-family: 'Fira Code', monospace;
}

.measure-delete {
  fill: var(--danger);
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  pointer-events: auto;
}

.measure-delete:hover {
  fill: #ff6b6b;
}

/* ==================== SATELLITE MAP MODE ==================== */

.leaflet-map {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
}

.map-mode .leaflet-map {
  display: block;
}

.map-mode .map-box {
  display: none;
}

.map-controls-panel {
  position: fixed;
  top: calc(var(--header-height) + 16px);
  right: 16px;
  width: 280px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  z-index: 1000;
  display: none;
  flex-direction: column;
  gap: 12px;
}

.map-mode .map-controls-panel {
  display: flex;
}

.map-controls-panel h3 {
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--text);
}

.map-control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.map-control-group label {
  font-size: 12px;
  color: var(--text-muted);
}

.address-search-wrapper {
  position: relative;
}

.address-search-wrapper input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--text);
  font-size: 14px;
}

.address-search-wrapper input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.address-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 6px 6px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 1001;
  display: none;
}

.address-suggestions.visible {
  display: block;
}

.address-suggestion {
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.address-suggestion:last-child {
  border-bottom: none;
}

.address-suggestion:hover,
.address-suggestion.selected {
  background: var(--primary);
  color: white;
}

.address-suggestion .suggestion-main {
  font-weight: 500;
}

.address-suggestion .suggestion-secondary {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.address-suggestion:hover .suggestion-secondary,
.address-suggestion.selected .suggestion-secondary {
  color: rgba(255,255,255,0.8);
}

.address-searching {
  padding: 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

.map-control-group .button-row {
  display: flex;
  gap: 8px;
}

.map-control-group .button-row .btn {
  flex: 1;
}

.map-control-group input[type="range"] {
  width: 100%;
}

.map-control-group .help-text {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

#opacityValue {
  font-size: 12px;
  color: var(--text);
  text-align: right;
}

.rotation-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rotation-control input[type="range"] {
  flex: 1;
}

.rotation-control .btn-small {
  padding: 4px 8px;
  min-width: 32px;
  font-size: 16px;
}

#overlayRotationValue {
  font-size: 12px;
  color: var(--text);
  min-width: 36px;
  text-align: right;
}

#exitMapModeBtn {
  margin-top: 8px;
}

/* Adjust mode button active state */
#adjustModeBtn.active {
  background: var(--warning);
  color: #000;
  font-weight: 600;
}

#adjustModeBtn.active:hover {
  background: #f59e0b;
}

/* Leaflet overrides for dark theme */
.leaflet-container {
  background: var(--bg);
  font-family: inherit;
}

.leaflet-control-zoom a {
  background: var(--card) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

.leaflet-control-zoom a:hover {
  background: var(--bg-secondary) !important;
}

.leaflet-control-attribution {
  background: rgba(0,0,0,0.6) !important;
  color: var(--text-muted) !important;
}

.leaflet-control-attribution a {
  color: var(--text-muted) !important;
}

/* Floor plan overlay on map - draggable corners */
.overlay-handle {
  width: 24px;
  height: 24px;
  background: var(--warning);
  border: 3px solid white;
  border-radius: 50%;
  cursor: move;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 0 2px var(--warning);
  transition: transform 0.15s, box-shadow 0.15s;
}

.overlay-handle:hover {
  transform: scale(1.3);
  box-shadow: 0 4px 12px rgba(0,0,0,0.6), 0 0 0 3px var(--warning);
}

.overlay-handle.center {
  background: var(--primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 0 2px var(--primary);
  width: 32px;
  height: 32px;
}

.overlay-handle.center:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.6), 0 0 0 3px var(--primary);
}

.overlay-handle.rotation {
  background: var(--success);
  cursor: grab;
}

/* Adjust mode - pulsing handles */
.adjust-mode .overlay-handle {
  animation: pulse-handle 1.5s ease-in-out infinite;
}

@keyframes pulse-handle {
  0%, 100% { box-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 0 2px var(--warning); }
  50% { box-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 0 6px rgba(245, 158, 11, 0.4); }
}

.adjust-mode .overlay-handle.center {
  animation: pulse-handle-center 1.5s ease-in-out infinite;
}

@keyframes pulse-handle-center {
  0%, 100% { box-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 0 2px var(--primary); }
  50% { box-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 0 6px rgba(59, 130, 246, 0.4); }
}

/* WiFi Coverage Circle */
.wifi-coverage {
  position: absolute;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  /* Radial gradient: solid at center, fading to transparent at edge */
  background: radial-gradient(circle,
    rgba(59, 130, 246, 0.4) 0%,
    rgba(59, 130, 246, 0.3) 30%,
    rgba(59, 130, 246, 0.15) 60%,
    rgba(59, 130, 246, 0) 100%
  );
  /* Blend overlapping coverage areas - shows brighter where multiple APs overlap */
  mix-blend-mode: screen;
  transition: background 0.3s ease;
}

/* Coverage layer background for proper blending */
#coverageLayer {
  isolation: isolate;
}

/* Same-channel interference warning - orange/red tint */
.wifi-coverage.interference {
  background: radial-gradient(circle,
    rgba(239, 68, 68, 0.5) 0%,
    rgba(239, 68, 68, 0.35) 30%,
    rgba(239, 68, 68, 0.2) 60%,
    rgba(239, 68, 68, 0) 100%
  );
}

/* Good overlap (different channels) - green tint */
.wifi-coverage.good-overlap {
  background: radial-gradient(circle,
    rgba(34, 197, 94, 0.4) 0%,
    rgba(34, 197, 94, 0.3) 30%,
    rgba(34, 197, 94, 0.15) 60%,
    rgba(34, 197, 94, 0) 100%
  );
}

/* Camera FOV Cone */
.camera-fov {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
  overflow: visible;
}

.camera-fov path {
  /* Filled by JS with gradient */
}

/* Camera rotation handle - draggable element */
.camera-rotation-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  background: rgba(34, 197, 94, 0.7);
  border: 2px solid white;
  border-radius: 50%;
  cursor: grab;
  pointer-events: auto;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
}

/* Show handle when marker is hovered or handle itself is hovered/active */
.marker:hover ~ .camera-rotation-handle,
.camera-rotation-handle:hover,
.camera-rotation-handle.visible,
.camera-rotation-handle.dragging {
  opacity: 1;
}

.camera-rotation-handle:hover {
  background: rgba(22, 163, 74, 0.9);
  transform: translate(-50%, -50%) scale(1.15);
}

.camera-rotation-handle:active,
.camera-rotation-handle.dragging {
  cursor: grabbing;
  opacity: 1;
}

/* Coverage layer - no pointer events (SVG overlays only) */
.coverage-layer {
  pointer-events: none;
}

/* Rotation handles in markers layer need pointer events */
.markers-layer .camera-rotation-handle {
  pointer-events: auto;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.2s;
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-header h2 {
  font-size: 14px;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.close-btn:hover {
  color: var(--text);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* Tooltip */
.tooltip {
  position: fixed;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
  max-width: 200px;
}

.tooltip.visible {
  opacity: 1;
}

.tooltip .name {
  font-weight: 600;
  margin-bottom: 2px;
}

.tooltip .type {
  color: var(--text-muted);
  font-size: 10px;
  text-transform: capitalize;
}

/* Legend */
.legend {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 10px;
  z-index: 50;
}

.legend.hidden-with-sidebar {
  right: calc(var(--sidebar-width) + 16px);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  color: var(--text-muted);
}

.legend-item:last-child {
  margin-bottom: 0;
}

.legend-item .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* Scale indicator */
.scale-indicator {
  position: fixed;
  bottom: 16px;
  left: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 11px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 100px;
}

.scale-bar {
  height: 4px;
  background: var(--primary);
  border-radius: 2px;
  width: 0;
  transition: width 0.3s ease;
}

.scale-indicator.has-scale .scale-bar {
  width: 60px;
}

.scale-label {
  color: var(--text-muted);
  font-size: 10px;
}

.scale-indicator.has-scale .scale-label {
  color: var(--text);
}

.scale-btn {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 10px;
  cursor: pointer;
}

.scale-btn:hover {
  background: #2563eb;
}

.scale-indicator.has-scale .scale-btn {
  background: var(--bg-secondary);
  color: var(--text-muted);
}

/* Ruler panel */
.ruler-panel {
  position: fixed;
  top: 70px;
  right: 16px;
  width: 280px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  z-index: 200;
  display: none;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.ruler-panel.visible {
  display: block;
}

.ruler-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.ruler-panel-header h3 {
  font-size: 14px;
  font-weight: 600;
}

.ruler-panel-body {
  padding: 16px;
}

.ruler-instructions p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.point-label {
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
}

.point-label.start {
  background: #22c55e;
  color: white;
}

.point-label.end {
  background: #ef4444;
  color: white;
}

.ruler-inputs label {
  font-size: 12px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 6px;
}

.pixel-display {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding: 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
}

.pixel-display strong {
  color: var(--primary);
}

.scale-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.scale-input-row input {
  flex: 1;
  min-width: 80px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
}

.scale-input-row input::-webkit-outer-spin-button,
.scale-input-row input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.scale-input-row select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text);
  font-size: 14px;
}

.ruler-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.ruler-actions .btn {
  flex: 1;
}

/* Ruler layer points */
.ruler-layer circle {
  cursor: move;
}

.ruler-layer circle.start {
  fill: #22c55e;
}

.ruler-layer circle.end {
  fill: #ef4444;
}

.ruler-layer line {
  stroke: var(--primary);
  stroke-width: 2;
  stroke-dasharray: 6 4;
}

/* Context menu */
.context-menu {
  position: fixed;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  z-index: 300;
  display: none;
  min-width: 120px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.context-menu.visible {
  display: block;
}

.context-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
}

.context-item:hover {
  background: var(--border);
}

/* Bulk actions bar (for multi-select) */
.bulk-actions {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  display: none;
  align-items: center;
  gap: 12px;
  z-index: 200;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.bulk-actions.visible {
  display: flex;
}

.bulk-actions .bulk-count {
  font-weight: 600;
  color: var(--warning);
}

.bulk-actions select {
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 13px;
}

.bulk-actions .btn {
  padding: 6px 12px;
  font-size: 13px;
}

.bulk-actions .btn.danger {
  display: flex;
  align-items: center;
  gap: 4px;
}

.bulk-actions .btn.danger svg {
  width: 14px;
  height: 14px;
}

.context-item[data-action="delete"] {
  color: var(--danger);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg);
  padding: 2px;
  border-radius: 6px;
  margin-bottom: 16px;
}

.tab {
  flex: 1;
  padding: 8px 12px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  font-size: 11px;
  transition: all 0.15s;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  background: var(--card);
  color: var(--text);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Photo and file upload buttons */
.photo-upload-buttons,
.file-upload-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.photo-upload-buttons .btn,
.file-upload-buttons .btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* Photo gallery */
.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.photo-gallery .photo-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg);
}

.photo-gallery .photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-gallery .photo-item .delete-photo {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  background: rgba(0,0,0,0.6);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.2s;
}

.photo-gallery .photo-item:hover .delete-photo {
  opacity: 1;
}

/* File list */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-list .file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 6px;
}

.file-list .file-item .file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.file-list .file-item .file-size {
  color: var(--text-muted);
  font-size: 12px;
}

.file-list .file-item .delete-file {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 4px;
}

/* Form elements */
label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
  letter-spacing: 0.5px;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="email"],
textarea,
select {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
  margin-bottom: 12px;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
}

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

.field-row {
  margin-bottom: 12px;
}

.field-row.checkbox label {
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: none;
  font-size: 12px;
  cursor: pointer;
}

.field-row.checkbox input {
  width: auto;
  margin: 0;
}

/* Utility classes */
.hidden {
  display: none !important;
}

.help-text {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ============================================
   RESPONSIVE / MOBILE STYLES
   ============================================ */

/* Tablet */
@media (max-width: 1024px) {
  :root {
    --header-height: 120px; /* May wrap to 2 rows on tablet */
  }

  .sidebar {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 200;
    transform: translateX(100%);
    transition: transform 0.3s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Overlay for sidebar */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;
  }

  .sidebar-overlay.visible {
    display: block;
  }
}

/* Mobile phones */
@media (max-width: 768px) {
  :root {
    --header-height: 56px; /* Single row header on mobile */
    --sidebar-width: 100%;
  }

  /* Hide desktop header rows on mobile */
  .header-row,
  .header-row-1,
  .header-row-2,
  .desktop-only {
    display: none !important;
  }

  /* Show mobile header */
  .mobile-only,
  .header-mobile {
    display: flex !important;
  }

  /* Header - single row on mobile */
  header {
    flex-direction: row;
    flex-wrap: nowrap;
    padding: 8px;
    gap: 8px;
    align-items: center;
    min-height: var(--header-height);
  }

  .header-mobile {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  /* Main content offset for mobile */
  main {
    margin-top: var(--header-height);
    height: calc(100vh - var(--header-height));
  }

  /* Mobile brand (AGD) */
  .mobile-brand {
    display: block !important;
    font-weight: bold;
    font-size: 14px;
    color: var(--primary);
    flex-shrink: 0;
  }

  /* Project selector - compact */
  .project-select {
    flex: 1;
    min-width: 80px;
    max-width: 120px;
  }

  .project-select select {
    flex: 1;
    min-width: 0;
    font-size: 11px;
    padding: 6px 4px;
    background: var(--card);
  }

  /* Mobile floor dropdown */
  .mobile-floor-select {
    display: block;
    flex: 1;
    min-width: 70px;
    max-width: 100px;
  }

  .mobile-floor-select select {
    width: 100%;
    padding: 6px 4px;
    font-size: 11px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
  }

  /* Toolbar - only essential buttons on mobile */
  .toolbar-buttons {
    flex: 0 0 auto;
    gap: 4px;
    flex-wrap: nowrap;
  }

  /* Add Marker button - compact */
  #addMarkerBtn {
    min-width: auto;
    padding: 6px 8px;
    font-size: 10px;
  }

  /* Mobile ruler button */
  .mobile-ruler-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    color: var(--text);
  }

  .mobile-ruler-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
  }

  /* Show hamburger menu on mobile */
  .mobile-menu-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    color: var(--text);
  }

  .mobile-menu-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
  }

  /* Scale indicator - hide on mobile, replace with size slider */
  .scale-indicator {
    display: none !important;
  }

  /* Mobile size slider - fixed to bottom left */
  .mobile-size-slider {
    display: flex !important;
    position: fixed;
    bottom: 16px;
    left: 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    z-index: 50;
    align-items: center;
    gap: 8px;
    font-size: 11px;
  }

  .mobile-size-slider label {
    color: var(--text-muted);
  }

  .mobile-size-slider input[type="range"] {
    width: 80px;
  }

  /* Mobile dropdown menu with sections */
  .mobile-menu {
    display: none;
    position: fixed;
    top: 52px;
    right: 8px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0;
    z-index: 250;
    min-width: 200px;
    max-width: 280px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  }

  .mobile-menu.visible {
    display: block;
  }

  .mobile-menu .menu-section {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
  }

  .mobile-menu .menu-section:last-child {
    border-bottom: none;
  }

  .mobile-menu .menu-section-title {
    padding: 4px 16px 8px;
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.5px;
  }

  .mobile-menu .menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    text-align: left;
  }

  .mobile-menu .menu-item:hover,
  .mobile-menu .menu-item:active {
    background: var(--hover);
  }

  .mobile-menu .menu-item svg {
    flex-shrink: 0;
    opacity: 0.7;
  }

  .mobile-menu .menu-item input[type="range"] {
    flex: 1;
    margin-left: auto;
    max-width: 80px;
  }

  /* Mobile filter section */
  .menu-filter-actions {
    display: flex;
    gap: 8px;
    padding: 0 12px 8px;
  }

  .menu-filter-btn {
    flex: 1;
    padding: 6px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
  }

  .menu-filter-btn:hover {
    border-color: var(--primary);
  }

  .menu-filters {
    padding: 0 12px;
    max-height: 200px;
    overflow-y: auto;
  }

  .menu-filter-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 4px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s;
  }

  .menu-filter-item:hover {
    background: var(--hover);
  }

  .menu-filter-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
  }

  .menu-filter-item .filter-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
  }

  .menu-filter-item .filter-name {
    flex: 1;
    font-size: 13px;
  }

  .menu-filter-item .filter-count {
    font-size: 11px;
    color: var(--text-muted);
  }

  /* Device filter dropdowns */
  .menu-section-subtitle {
    padding: 8px 16px 4px;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.3px;
  }

  .device-filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
  }

  .device-filter-row label {
    font-size: 12px;
    color: var(--text-muted);
    min-width: 80px;
  }

  .device-filter-row select {
    flex: 1;
    padding: 6px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: 12px;
    cursor: pointer;
  }

  .device-filter-row select:focus {
    outline: none;
    border-color: var(--primary);
  }

  /* Main content area */
  main {
    padding-top: 0 !important;
  }

  /* Map container - full viewport with single row header */
  .map-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding-top: 56px; /* Single row header height (~48px) + padding */
    overflow: auto; /* Allow scrollable content for JS pan */
    touch-action: none; /* CRITICAL: Disable browser touch handling - JS controls all gestures */
  }

  /* Sidebar as full-screen bottom sheet */
  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    height: 70vh;
    width: 100%;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }

  .sidebar.open {
    transform: translateY(0);
  }

  .sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
  }

  /* Handle for dragging sidebar */
  .sidebar-header::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 12px;
  }

  /* Sidebar content scrollable */
  .sidebar-content {
    max-height: calc(70vh - 60px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
  }

  /* Legend - hide on mobile to reduce clutter */
  .legend {
    display: none;
  }

  /* Scale indicator */
  .scale-indicator {
    bottom: 60px;
  }

  /* Context menu - larger touch targets */
  .context-menu {
    min-width: 180px;
  }

  .context-item {
    min-height: 48px;
    font-size: 14px;
  }

  /* Modals - full screen on mobile */
  .modal {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    margin: 0;
  }

  .modal-header {
    padding: 16px;
  }

  .modal-body {
    padding: 16px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal-footer {
    padding: 16px;
    position: sticky;
    bottom: 0;
    background: var(--card);
    border-top: 1px solid var(--border);
  }

  /* Form elements - larger touch targets */
  input,
  select,
  textarea {
    min-height: 44px;
    font-size: 16px; /* Prevents iOS zoom */
    padding: 12px;
  }

  .btn {
    min-height: 44px;
    padding: 12px 16px;
    font-size: 14px;
  }

  /* Tabs - larger touch targets */
  .tabs .tab {
    min-height: 44px;
    padding: 12px 16px;
  }

  /* Ruler panel */
  .ruler-panel {
    bottom: auto;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: calc(100% - 32px);
    max-width: 320px;
  }

  /* Tooltip - hidden on touch devices (use tap instead) */
  .tooltip {
    display: none;
  }
}

/* Extra small phones */
@media (max-width: 375px) {
  header h1 {
    font-size: 10px;
  }

  .project-select select {
    font-size: 14px;
  }

  .floor-tab {
    padding: 8px 12px;
    font-size: 11px;
  }

  .toolbar-buttons .btn {
    min-width: 40px;
    min-height: 40px;
  }
}

/* Touch device optimizations */
@media (pointer: coarse) {
  /* Disable hover effects */
  .btn:hover,
  .filter-btn:hover,
  .floor-tab:hover {
    transform: none;
  }
}

/* Landscape mode on mobile */
@media (max-height: 500px) and (orientation: landscape) {
  header {
    padding: 4px 8px;
  }

  header h1 {
    display: none;
  }

  .floor-tab {
    min-height: 36px;
    padding: 6px 12px;
  }

  .sidebar {
    height: 100vh;
    max-height: 100vh;
  }

  .modal {
    max-height: 100vh;
  }
}

/* Drag-drop device assignment */
.device-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  cursor: grab;
  transition: all 0.2s ease;
  position: relative;
}

.device-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.device-card.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.device-card.assigned {
  opacity: 0.6;
  cursor: default;
  border-color: var(--success);
}

.device-card .ip {
  font-weight: 600;
  font-family: 'Fira Code', monospace;
  color: var(--primary);
}

.device-card .mac {
  font-family: 'Fira Code', monospace;
  font-size: 0.85em;
  color: var(--text-muted);
}

.device-card .hostname {
  font-size: 0.9em;
  color: var(--text);
}

.device-card .os {
  font-size: 0.8em;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 4px;
}

.device-card .services {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.service-tag {
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75em;
  font-family: 'Fira Code', monospace;
  color: var(--text-muted);
}

.assigned-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--success);
  color: white;
  font-size: 0.7em;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.nmap-results {
  margin-top: 16px;
}

.nmap-results h3 {
  margin-bottom: 12px;
  font-size: 1em;
}

.nmap-results .help-text {
  font-size: 0.85em;
  color: var(--text-muted);
  margin-top: 12px;
}

/* NMAP Assignment Modal */
.nmap-assign-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: calc(80vh - 140px);
  min-height: 400px;
}

.nmap-assign-selection {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  flex: 1;
  min-height: 0;
}

.nmap-assign-column {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: 6px;
  overflow: hidden;
  min-height: 0;
}

.nmap-column-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.nmap-column-header h3 {
  margin: 0 0 8px 0;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
}

.nmap-column-header .count {
  font-weight: normal;
}

.nmap-search {
  width: 100%;
  padding: 8px 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
}

.nmap-search:focus {
  outline: none;
  border-color: var(--primary);
}

.nmap-device-list,
.nmap-marker-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  min-height: 0;
}

/* Selectable items in lists */
.nmap-list-item {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}

.nmap-list-item:hover {
  border-color: var(--primary);
  background: var(--card);
}

.nmap-list-item.selected {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.15);
}

.nmap-list-item.assigned {
  opacity: 0.5;
  border-color: var(--success);
}

.nmap-list-item .item-title {
  font-weight: 600;
  font-size: 13px;
}

.nmap-list-item .item-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'Fira Code', monospace;
}

.nmap-list-item .item-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

.nmap-list-item .services {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.nmap-list-item .service-tag {
  font-size: 9px;
  padding: 2px 5px;
  background: var(--card);
  border-radius: 3px;
  font-family: 'Fira Code', monospace;
}

.nmap-list-item .assigned-badge {
  position: absolute;
  top: 8px;
  right: 8px;
}

/* Comparison Table */
.nmap-comparison {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
}

.comparison-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.comparison-header h3 {
  margin: 0;
  font-size: 14px;
}

.comparison-table {
  display: table;
  width: 100%;
  font-size: 12px;
}

.comparison-row {
  display: table-row;
}

.comparison-row:hover {
  background: var(--bg);
}

.comparison-cell {
  display: table-cell;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.comparison-row:last-child .comparison-cell {
  border-bottom: none;
}

.comparison-cell.checkbox {
  width: 30px;
  text-align: center;
}

.comparison-cell.field-name {
  width: 100px;
  font-weight: 500;
  color: var(--text-muted);
}

.comparison-cell.current-value {
  color: var(--text-muted);
  font-family: 'Fira Code', monospace;
}

.comparison-cell.new-value {
  font-family: 'Fira Code', monospace;
}

.comparison-cell.new-value.will-change {
  color: var(--warning);
  font-weight: 500;
}

.comparison-cell.new-value.will-add {
  color: var(--success);
  font-weight: 500;
}

.comparison-cell.new-value.no-change {
  color: var(--text-muted);
}

.comparison-cell.arrow {
  width: 30px;
  text-align: center;
  color: var(--text-muted);
}

/* Empty state */
.nmap-empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.nmap-empty-state i {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .nmap-assign-body {
    height: auto;
    max-height: calc(80vh - 140px);
  }

  .nmap-assign-selection {
    grid-template-columns: 1fr;
    flex: none;
  }

  .nmap-assign-column {
    max-height: 35vh;
  }

  .comparison-cell.current-value,
  .comparison-cell.arrow {
    display: none;
  }
}

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--card);
  color: var(--text);
  padding: 12px 24px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  z-index: 10000;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Progress Overlay */
.progress-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10001;
}

.progress-overlay.visible {
  display: flex;
}

.progress-content {
  background: var(--card);
  padding: 30px 40px;
  border-radius: 12px;
  text-align: center;
  min-width: 300px;
  border: 1px solid var(--border);
}

.progress-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 20px;
  animation: spin 1s linear infinite;
}

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

.progress-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.progress-status {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.3s ease;
}

/* Print styles */
@media print {
  header,
  .toolbar-buttons,
  .sidebar,
  .legend,
  .scale-indicator,
  .ruler-panel {
    display: none !important;
  }

  main {
    padding: 0 !important;
  }

  .map-container {
    position: static;
    overflow: visible;
  }
}
