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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  min-height: 100vh;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  background: #16213e;
  border-bottom: 1px solid #0f3460;
}

header h1 {
  font-size: 1.5rem;
  color: #FFE4B5;
  letter-spacing: 0.05em;
}

.header-controls {
  display: flex;
  gap: 0.75rem;
}

button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.2s;
}

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

#add-device {
  background: #0f3460;
  color: #FFE4B5;
}

#add-device:hover:not(:disabled) {
  background: #1a4a8a;
}

.secondary {
  background: transparent;
  color: #888;
  border: 1px solid #333;
}

.secondary:hover {
  background: #222;
}

/* Device grid */
#device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

/* Device card */
.device-card {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.device-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.device-card-header h3 {
  font-size: 0.875rem;
  color: #888;
  font-weight: 400;
}

.device-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: #666;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #444;
}

.status-dot.online {
  background: #4caf50;
}

.remove-device {
  background: transparent;
  color: #666;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  border: 1px solid #333;
}

.remove-device:hover {
  color: #e74c3c;
  border-color: #e74c3c;
}

/* SVG container */
.svg-container {
  width: 100%;
  max-width: 250px;
  margin: 0 auto;
  position: relative;
}

.svg-container svg {
  width: 100%;
  height: auto;
  display: block;
}

.svg-container #ultrasonicsensor {
  cursor: pointer;
  transition: filter 0.15s;
}

.svg-container #ultrasonicsensor:hover {
  filter: brightness(1.3);
}

/* Device ID fields */
.device-fields {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.device-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.device-field label {
  font-size: 0.7rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.device-field input {
  background: #0d1b2a;
  border: 1px solid #1a3a5c;
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  color: #e0e0e0;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  width: 100%;
}

.device-field input:focus {
  outline: none;
  border-color: #FFE4B5;
}

.device-field input::placeholder {
  color: #333;
  text-transform: none;
  letter-spacing: normal;
}

/* Motion indicator */
.motion-indicator {
  text-align: center;
  font-size: 0.75rem;
  color: #666;
  min-height: 1.2em;
  transition: color 0.3s;
}

.motion-indicator.active {
  color: #FFE4B5;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 12px;
  padding: 2rem;
  max-width: 500px;
  width: 90%;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: transparent;
  color: #888;
  font-size: 1.25rem;
  padding: 0.25rem 0.5rem;
}

.modal-content h2 {
  margin-bottom: 1rem;
  font-size: 1.1rem;
  color: #FFE4B5;
}

.modal-content ol {
  padding-left: 1.25rem;
  line-height: 1.8;
  font-size: 0.9rem;
  color: #bbb;
}

.modal-content strong {
  color: #e0e0e0;
}

.modal-content form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-content label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: #bbb;
}

.modal-content input {
  background: #0d1b2a;
  border: 1px solid #1a3a5c;
  border-radius: 4px;
  padding: 0.5rem;
  color: #e0e0e0;
  font-size: 0.9rem;
}

.modal-content input:focus {
  outline: none;
  border-color: #FFE4B5;
}

.modal-content button[type="submit"] {
  background: #0f3460;
  color: #FFE4B5;
  padding: 0.6rem;
  margin-top: 0.5rem;
}

.modal-content button[type="submit"]:hover {
  background: #1a4a8a;
}

.hidden {
  display: none !important;
}
